Unity's serializationserialization system doesn't support inheritance for custom serializable class. In order to correctly serialize fields of a polymorphic type it must be derived from MonoBehaviourMonoBehaviour
or ScriptableObjectScriptableObject
.
For your example BaseClass should extend MonoBehaviourMonoBehaviour
to make it work.
In addition, custom serialized class references won't be resolved. This means that if 2 class A
have a field referencing the same instance of a class B
, the 2 field will be serialized separately and so you'll end up with 2 instance of class B
one assigned to each field of the class A
.