I have these two classes:
public class MyParent
{
public string a;
public MySub[] b;
}
public class MySub
{
public int sub;
}
I initialize them like this:
myPC = new MyParent();
myPC.a = "test";
myPC.b = new MySub[2];
myPC.b[0] = new MySub();
myPC.b[1] = new MySub();
myPC.b[0].sub = 1;
myPC.b[2].sub = 2;
But when I serialize the object, The result is only {"a":"test"}
string json = JsonUtility.ToJson(myPC);
Debug.Log(json); // {"a":"test"}
How do I do that correctly and convert JSON back to an object?