Hello. Just purchased an asset today.
Wanted to use it for the following scenario: I have one game object that holds some data and I want to save the entire game object for simplicity. The game object is a "persistent singleton" (DontDestroyOnLoad), so it will travel between the scenes, destroy other objects with the same script in Awake(). I have created a type for it in E3 settings. For simplicity, just trying to get one int field saved.
The behavior that I expect: I can start in one scene. Ex: Menu. Then load a different scene, make some changes to the values on that object. When I quit the game, all the values will be saved.
The behavior that I get instead:
If I start in one scene and quit the game in the same scene, the data gets saved correctly.
If I start the game in one scene, load the next scene and quit from that next scene, the object does not get saved. I suspect it has something to do with that scene not having a reference to this game object because it arrived from a different scene.
I tried it with both manual saving in OnApplicationQuit with a line like: ES3.Save<GameObject>("storage", gameObject); and with the automatic saving component and I get the same result.
Any advice on how I can get this game object saved regardless of the scene that I quit the application from? Any additional info that you'd like me to provide?
Thank you!
Saving and loading an object only works in the same scene
Re: Saving and loading an object only works in the same scen
Hi there,
The issue is that the references which that GameObject relies on will not exist in the scene you are loading.
One way you can ensure that the references are persisted in the following scene is to also set the Easy Save 3 Manager to DontDestroyOnLoad. When Easy Save detects two Easy Save 3 Managers in a scene, the reference lists of those managers will be merged.
All the best,
Joel
The issue is that the references which that GameObject relies on will not exist in the scene you are loading.
One way you can ensure that the references are persisted in the following scene is to also set the Easy Save 3 Manager to DontDestroyOnLoad. When Easy Save detects two Easy Save 3 Managers in a scene, the reference lists of those managers will be merged.
All the best,
Joel