Page 1 of 1

ES3 JSON Reader Error When Loading into Empty Array

Posted: Thu May 02, 2019 11:59 pm
by erik
Hi,

I'm trying to load a saved array of objects to be used in a method that sets everything back up as normal. Since I don't want ES3 to generate new GameObjects, I created a new empty array of those objects, and I'm using the ES3.LoadInto method to load the saved array into.

Code looks like this:

Code: Select all

RegrowingFoodPlant_Yield[] yield = new RegrowingFoodPlant_Yield[0];
                        
ES3.LoadInto("plantyield" + i, SaveSlotManager.getCurrentSaveSlotString(), yield);
Then when trying to load my game, I get the following error: FormatException: Expected '}', found '{'. ES3Internal.ES3JSONReader.ReadCharIgnoreWhitespace (System.Char expectedChar)

Please advise :)
Erik

Re: ES3 JSON Reader Error When Loading into Empty Array

Posted: Fri May 03, 2019 7:52 am
by Joel
Hi there,

I think you might misunderstand the purpose of LoadInto. This is supposed to be an array of existing GameObjects to load the data into, not an empty array.

However, for GameObjects this does nothing as they are resolved by reference. Easy Save will only create new GameObjects if there are no GameObjects in the reference manager with the reference ID we are trying to load.

If your GameObjects are not instantiated at runtime, this is usually because automatic reference updating has been disabled and the reference manager needs updating. You can do this by clicking the Easy Save 3 Manager in your scene and then pressing the "Update References" button on the ES3ReferenceMgr component.

If your GameObjects are instantiated at runtime, you need to follow the Saving and loading prefab instances instructions here, otherwise it's not possible for Easy Save to know that your prefab exists.

All the best,
Joel

Re: ES3 JSON Reader Error When Loading into Empty Array

Posted: Sat May 04, 2019 2:57 am
by erik
Hmm maybe you could help me understand how to resolve what I'm trying to do. I have a method that takes in an array of RegrowingFoodPlant_Yield objects and uses the data to build prefabs and copy the variables from the array into. I'm using ES3.Save to save the arrays, and now I'm trying to load them into an instance variable so I can pass them into the instantiation method. I stopped using LoadInto and swapped to:

Code: Select all

RegrowingFoodPlant_Yield[] yield = ES3.Load<RegrowingFoodPlant_Yield[]>("plantyield" + i, SaveSlotManager.getCurrentSaveSlotString());
but it seems now I'm getting a "Non-static field requires a target System.Reflection.MonoField.SetValue" error. Not sure what I'm doing wrong this time but hopefully you can help.

Thanks

Re: ES3 JSON Reader Error When Loading into Empty Array

Posted: Sat May 04, 2019 6:45 am
by Joel
Hi there,

Would you be able to PM me a basic project and instructions to replicate this so I can see what is happening?

All the best,
Joel