FindPropertyRelative with Polymorphed class member returns null...Please help!

Hi Everyone:)
Let’s say I have the following classes:

public class A
{
      [SerializeField] Base base;
      ....
}

public class Base
{
...
}

public class Child : Base
{
     ...
}

}

*Assume that ‘base’ member in class ‘A’ contains a reference to ‘Child’ class

When I try to add a property drawer to class A and try to find the member ‘base’ with the FindPropertyRelative method (so I can draw the ‘child’ class in the inspector) it always returns null for some reason :eyes:
Also, when I use a reference to ‘Child’ (replace the ‘Base’ member reference with the ‘Child’ reference it works!

Can someone help me with this?

Thanks:)

Anyone? :hushed:

Maybe don’t name your property ‘base’ which is a keyword in C#. And put the code of your property drawer to have more informations.

I thought it was clear enough, but I may be wrong

Found a solution:

1 Like

Basically, If I want to serialize a derived class that is saved in a parent reference, I need the parent to inherit from ScriptableObject.
Also, the class that inherites from the ScriptableObject need to reside in it’s own class, otherwise, it wont work!

1 Like