Saved List of Custom Class Not Loading Correctly

Discussion and help for Easy Save 3
Post Reply
DeliInteractive
Posts: 9
Joined: Sat Feb 27, 2021 4:03 am

Saved List of Custom Class Not Loading Correctly

Post by DeliInteractive »

Hi Joel,

Recently we've run into an issue with Easy Save in our project when trying to save a List of a custom class in our game ("Item"). Up until now this worked perfectly fine for saving lists of "items" in our player's inventory by saving the Player Prefab itself with an "Inventory" class registered as an Easy Save UserType that simply contains the list of "Items"

More recently this stopped working when certain "Items" no longer loaded between play sessions, instead loading null data. These new items do not differ in any major way besides the fact that they were created recently. We managed to recreate this problem in an empty Unity Project by importing working "items" directly from our Unity project, and then making new "items" either by duplicating or creating new prefab variants. The newly created prefabs will not load, while the original ones will.

To recreate:

- Open the Unity Project.
- Enter Playmode.
- A "TestObject" should be instantiated into the scene. Drag various items from the Prefabs folder into its public empty "inventory" to change its contents.
- Press "S" to Save.
- Exit Playmode.
- Enter Playmode again and press "L" to load in the saved prefab.
- Note how "WorkingItemGuy" and "WorkingItemGal" will load correctly, while any other item type will fail to load.

We'd love to know what exactly seems to be happening here that makes some items load and others fail. It seems that duplicating objects is a sure-fire way to get them to fail, but creating brand new objects and attaching the "Item" component to them manually has had the same result. Nothing other than newness seems to connect these things, so we'd be very curious to find out what's going on here and if there's any way you can help us resolve this issue.

We'll attach the empty project in a private message.

Thanks for your time,

Nick Lives, Deli Interactive LLC
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saved List of Custom Class Not Loading Correctly

Post by Joel »

Hi Nick, and thanks for sending that over.

The issue is that the other prefabs have never been dependencies of that scene, so that scene has no knowledge of those prefabs existing.

In this case you can select the prefabs outside of runtime and right-click > Easy Save 3 > Add Reference(s) to Manager. This will make them a dependency of the scene. Alternatively you can simply create an array in that scene which contains all of the prefabs which you are going to reference so that they become a dependency of the scene.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply