Unable to load Json to an object array

Basically when the save function is called it only seems to save the InsanceIds to the json file please see attached save.txt file (maybe on a separate post due to upload limit).
alt text
when I do a Debug.Log, if I type just wrap I just get a JobManagerWrapper object, if I type wrap.array then I get JobManager, if I type wrap.array[0] then I get Job1[jobManager]

Please see attached screenshots for breakpoints results from the save.alt text (have to put the 2nd in a separate post as it wont allow me to add anymore attachments).

On Loading its passed all the instanceIDs that are in the save.txt, when I do a Debug.Log(j.array[0].jobStatus)) it’s set to 0 and it should be 1 as in the save before that’s what it was set to.

public static void Save()
        JobManagerWrapper wrap = new JobManagerWrapper();
        wrap.array = Resources.LoadAll<JobManager>("Jobs");
        string jsonData = JsonUtility.ToJson(wrap);

        File.WriteAllText(Application.persistentDataPath + "/save.txt", jsonData);

    public static void Load()
        if (FileCheck())
            string jsonData = File.ReadAllText(Application.persistentDataPath + "/save.txt");
            JobManagerWrapper j = JsonUtility.FromJson<JobManagerWrapper>(jsonData);
            Debug.LogError("Save file not found");

public class JobManagerWrapper
    public JobManager[] array;


Ok after testing and researching this topic myself it looks like the problem is Unity’s serialization ways, when you serialize a single object it gives the correct output because it has to look into the contents of the object. However, when you pass it an object with an array of references, like in your case, Unity says, these are references to Objects (Unity’s own object type that contains instanceID) so it will be better if I save the ID from this instead since you can fetch it by ID later (this is my guess).

So the options I can come up with for you are:

1) Once again, switch to Json .NET or any other json library, just stop using JsonUtility.

2) Create a proxy object which is a plain C# class that has the same properties as the scriptable object and change the wrapper class to use those instead in the array. Then have a method on your scriptable object that returns an fresh instance of the proxy type with it’s properties already set, so when you get the array of JobManagers using Resources.LoadAll you can call that method and populate the wrapper’s array more easily.


Note: Also stop calling Load in the scriptable object’s Awake method, it is a bad idea to do so. Use a button or some monobehaviour’s awake/start instead.