Search Unity

Deserialise objects casts them to superclass?

Discussion in 'Scripting' started by BlackArcane, Feb 27, 2015.

  1. BlackArcane

    BlackArcane

    Joined:
    Jun 26, 2011
    Posts:
    119
    I am facing the following problem: I have a List of Serializable classes that are created using a custom editor. When entering play mode, the list is preserved, as expected, but any objects in it are turned into their superclass. For example if i have a list of 'Move' which contains some 'SpecialMove' which inherits from move it is turned into 'Move' on play mode. Any ideas on why it happens and how I can work around it?

    EDIT: It turns out Unity's serializer is the cause for this. Apparently it does not support polymorphism concepts. Any work arounds?
     
    Last edited: Feb 27, 2015
  2. billykater

    billykater

    Joined:
    Mar 12, 2011
    Posts:
    329