Hi, I'm a college student working on a final year project and I've just bought this package yesterday.
It's working great for the most part, but my main issue is as the title says. I have a prefab that holds the vast majority of my character data, things like money and a list of owned properties and things like that. This prefab exists in the Start scene and the Gameplay scene, the version in the Start scene has a Don't destroy on it, so it replaces the one in the Gameplay scene, which exists for serialization and the like.
My issue is that I need to save data from the Gameplay, or I suppose, DoNotDestroy scene and load it into the prefab in the Start scene. I've taken a look around and can't see a way to do this, though I am very unfamiliar with this package so any guidance would be fantastic. At the moment, anything that is changed during the start scene is properly saved and loaded into the start scene but not the gameplay scene, though it IS still saved. So I know that I do have the package set up correctly and its working to some degree, it just can't tell that I want it to save and load to prefabs directly I suppose?
Thanks for your help!
Save and load data to and from different instances of a prefab in two scenes?
Re: Save and load data to and from different instances of a prefab in two scenes?
Hi there, and thanks for getting in contact
Generally you would do this using the ES3.LoadInto method to tell Easy Save which instance you want to load the data into:
https://docs.moodkie.com/easy-save-3/es ... -loadinto/
This won't work however if your prefab has children as these need to be loaded by reference. In this case instead of saving the entire GameObject, you should save each individual Component and use ES3.LoadInto to load these into the Components on the prefab.
All the best,
Joel
Generally you would do this using the ES3.LoadInto method to tell Easy Save which instance you want to load the data into:
https://docs.moodkie.com/easy-save-3/es ... -loadinto/
This won't work however if your prefab has children as these need to be loaded by reference. In this case instead of saving the entire GameObject, you should save each individual Component and use ES3.LoadInto to load these into the Components on the prefab.
All the best,
Joel
Re: Save and load data to and from different instances of a prefab in two scenes?
Thanks for the quick response!
My prefab is pretty complicated, there's a lot of nested prefabs inside of it which then in turn have a lot of prefabs inside of them. Is there any way to do this while still making use of the auto save/load functionality? I'm not really sure how to approach this at all.
My prefab is pretty complicated, there's a lot of nested prefabs inside of it which then in turn have a lot of prefabs inside of them. Is there any way to do this while still making use of the auto save/load functionality? I'm not really sure how to approach this at all.
Re: Save and load data to and from different instances of a prefab in two scenes?
Hi there,
Auto Save is intended to load in the same scene as you saved in, as it relies on loading by reference. This isn't possible if you're loading in difference scenes or using DontDestroyOnLoad (as the object no longer exists in any persistent scene).
If taking the saving and loading Components approach using LoadInto, you would simply do the following:
And the following to load:
All the best,
Joel
Auto Save is intended to load in the same scene as you saved in, as it relies on loading by reference. This isn't possible if you're loading in difference scenes or using DontDestroyOnLoad (as the object no longer exists in any persistent scene).
If taking the saving and loading Components approach using LoadInto, you would simply do the following:
Code: Select all
// To save Components
ES3.Save("myComponent", prefab.GetComponent<MyComponent>());
ES3.Save("myOtherComponent", prefab.GetComponent<MyOtherComponent>());
// etc
Code: Select all
// To load Components
ES3.LoadInto("myComponent", prefab.GetComponent<MyComponent>());
ES3.LoadInto("myOtherComponent", prefab.GetComponent<MyOtherComponent>());
// etc
Joel
Re: Save and load data to and from different instances of a prefab in two scenes?
Thank you! I'll give this a shot!