public void OnBeforeSerialize() { for (int i = 0; i < GetallSerializableFields().Length; i++) { GetallSerializableFields()[i].SetValue(this, DeepSerial.DeserializeToProperType(((DeepSerial)GetallSerializableFields()[i].GetValue(this)))); } }
public static DeepSerial DeserializeToProperType(DeepSerial deepSerial) { if (deepSerial == null) { return(null); } if (deepSerial.GetType() != deepSerial.DerivedClassType) { return((DeepSerial)JsonUtility.FromJson(deepSerial.serials, deepSerial.DerivedClassType)); } else { return(deepSerial); } }