Hey guys !
I’m having a really weird (and annoying issue) at the moment…
Basically let’s say I have something like this… (sorry I don’t like copy/pasting code but it should be easier to explain with this simple test code…)
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
[System.Serializable]
public abstract class BaseClass : ScriptableObject
{
public enum eType
{
Type1 = 0,
Type2,
// etc..
}
public eType m_Type = eType.Type1;
public bool m_Enabled = true;
public virtual void Awake()
{
Debug.Log(m_Type + " Enabled = " + m_Enabled);
}
}
[System.Serializable]
public class Type1Class : BaseClass
{
public GameObject m_PrefabToInstantiate = null; // 3
public enum eSecondaryType
{
AAA = 0,
BBB,
CCC,
}
[SerializeField] // 1
public eSecondaryType m_SecondaryType = eSecondaryType.AAA;
[SerializeField] // 2
public bool m_MySecondaryBool = true;
public Transform m_Transform; // 4
public Type1Class()
{
m_Type = BaseClass.eType.Type1;
}
public override void Awake()
{
base.Awake();
Debug.Log("From Type1Class: SecondaryType = " + m_SecondaryType + " MySecondaryBool = " + m_MySecondaryBool);
}
}
In the editor when I start my game, everything’s working fine…
The Awake Functions both display what I’m expecting, so the serialisation is working here… meaning Type and SecondaryType both display what I have in the UI (same for the 2 test booleans)
But strangely on iOS, the Awake function of Type1Class always return the default values… where it’s all fine for the BaseClass
It’s like if the serialisation was only done for the base class only…
Note that removing serialisation fields (markers 1 and 2) doesn’t change anything at all and still can’t get correct serialised values for m_SecondaryType and m_SecondaryBool
But it’s not totally not working as the GameObject and Transform members are both correct… (markers 3 & 4)
I guess I must be missing something obvious here related to basic type…
I will tomorrow try with other type like string or int…
Don’t tell me to use MonoBehavior instead of ScriptableObject for my BaseClass it’s just not possible for the design of the system I’ve implemented…
Anyway I have seriously no idea what is going on… so please if you have any idea don’t hesitate as I’m really stuck on that right now… and it’s pretty frustrating !