Issue with loading a list of objects

Discussion and help for Easy Save 3
Post Reply
DMCH
Posts: 16
Joined: Mon Jun 16, 2014 2:26 pm

Issue with loading a list of objects

Post by DMCH »

Hi,

I've set up ItemSaveData as an ES3 type and am trying to save and load of list of this object type. Single instances are saving and loading correctly. A nudge in the right direction would be appreciated!

Saving

Code: Select all

// Save Equipped Items
saveFileIn.Save<ItemSaveData>("char" + i + "EquippedItems", ReturnCharacterEquippedItemData(thisCharContainer));
Loading

Code: Select all

// Load Equipped Items
List <ItemSaveData> equippedItems = loadFileIn.Load<List<ItemSaveData>>("char" + i + "EquippedItems");  Note: This is line 425
gameDataScript.AddSavedEquippedItems(loadedCharContainer, equippedItems, false);
Error Message

Code: Select all

FormatException: Expected '[' or "null", found '{'.
ES3Internal.ES3JSONReader.ReadNullOrCharIgnoreWhitespace (Char expectedChar) (at C:/My Folder/And Prometheus Wept/Current Code/APW - V0.36/Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:390)
ES3Internal.ES3JSONReader.StartReadCollection () (at C:/My Folder/And Prometheus Wept/Current Code/APW - V0.36/Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:157)
ES3Types.ES3ListType.Read (.ES3Reader reader) (at C:/My Folder/And Prometheus Wept/Current Code/APW - V0.36/Assets/Plugins/Easy Save 3/Scripts/Types/Collection Types/ES3ListType.cs:53)
ES3Reader.Read[List`1] (ES3Types.ES3Type type) (at C:/My Folder/And Prometheus Wept/Current Code/APW - V0.36/Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:240)
ES3File.Load[List`1] (System.String key) (at C:/My Folder/And Prometheus Wept/Current Code/APW - V0.36/Assets/Plugins/Easy Save 3/Scripts/ES3File.cs:207)
LoadSaveManager.LoadPlayerTeam (.ES3File loadFileIn) (at Assets/Scripts/Save & Load Scripts/LoadSaveManager.cs:425)
LoadSaveManager.LoadGame (System.String loadFileLocation) (at Assets/Scripts/Save & Load Scripts/LoadSaveManager.cs:76)
GameOptionsScript.LoadGame () (at Assets/Scripts/Game Logic Scripts/GameOptionsScript.cs:2591)
UnityEngine.Events.InvokableCall.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:166)
UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:58)
UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:36)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:45)
UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update()

User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Issue with loading a list of objects

Post by Joel »

Hi there,

You appear to be saving individual ItemSaveData's, not a List<ItemSaveData>.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
DMCH
Posts: 16
Joined: Mon Jun 16, 2014 2:26 pm

Re: Issue with loading a list of objects

Post by DMCH »

Ugh, careless of me. Thanks, Joel.
Post Reply