Hello. I have the following classes:
[System.Serializable]
class A
{
public float a = 50f;
public float b = 100f;
//rest of class...
}
[System.Serializable]
class B
{
public A[] myArray;
//rest of class...
}
class C : MonoBehaviour
{
public B myB;
//rest of class...
}
For some reason every time I create a new element for “myArray” in the editor, it gets created with a=0 and b=0, and I would want to have the default values 50f and 100f.
Has anyone encountered this and know what causes it? I should also mention that I have a custom editor for class C that just adds some buttons like so:
[CanEditMultipleObjects]
[CustomEditor(typeof(C))]
public class C: Editor
{
public override void OnInspectorGUI()
{
if(GUILayout.Button("Do something"))
{
//....
}
base.OnInspectorGUI();
}
}
Thank you for your time