hi guys, is there a reason that this:
[System.Serializable]
public class ExampleClass : ScriptableObject
{
[SerializeField]
public List<ParentClass> exampleClasses = new List<ParentClass>()
{
new ParentClass(),
new ChildClass()
};
}
[System.Serializable]
public class ParentClass
{
}
[System.Serializable]
public class ChildClass : ParentClass
{
}
would serialize to be a list with two ParentClass elements instead of one ParentClass and one ChildClass. Is it because of the [serializefield] attribute before the list? if so how can I serialize this whilst still respecting the classes I want?
Unity does not support polymorphic serialization, so every list element will just serialize as a ParentClass. You might find my response to this question helpful.