1
// a is an InputField where class InputField : X, Y, Z
Debug.Log(a.GetType().BaseType.Name)

The above code only returns X and not X and Y. Is there a way to get all 3?

GregWringle
  • 445
  • 3
  • 6
  • 16

1 Answers1

2

C# does not support multiple inheritence although I know that X, Y, Z syntax looks like it does.

X is always your BaseType and Y and Z are considered interfaces.

See: Multiple Inheritance in C#

So, no, it's not possible to get base classes from inheriting class because there is only one base class.

If you want to see what interfaces are implemented, your best bet is reflection. That's a whole topic in itself but see the following:

System.Reflection.MemberInfo info = typeof(MyClass);
object[] attributes = info.GetCustomAttributes(true);
for (int i = 0; i < attributes.Length; i++)
{
  print(attributes[i]);
}

Source: http://www.tutorialspoint.com/csharp/csharp_reflection.htm

Community
  • 1
  • 1
slumtrimpet
  • 3,159
  • 2
  • 31
  • 44