I have these Prefabs
with this script on them
The prefabs(tubasedcards) are referenced on another prefab in list form
That list supplies my save prefab that save and loads lists for cards unlocked.
Now when I, in the prefab (game no running) change a variable, it can be int, float or gameobject.
It will revert to previous setting when I press play?
How do I avoid that?
I tried adding the prefab to the refencemanager didn't work.
Prefab changes variables back to previous version on play.
Re: Prefab changes variables back to previous version on play.
Hi there,
Please could you show me the code you're using to load? Also what is the data you're saving? A List of GameObjects? If so, just to check, have you followed the Saving and Loading GameObjects guide?
https://docs.moodkie.com/easy-save-3/es ... s-prefabs/
All the best,
Joel
Please could you show me the code you're using to load? Also what is the data you're saving? A List of GameObjects? If so, just to check, have you followed the Saving and Loading GameObjects guide?
https://docs.moodkie.com/easy-save-3/es ... s-prefabs/
This is expected behaviour, no? Because it will load the variables from the save data when you start the game, overriding whatever you've set outside of playmode.Now when I, in the prefab (game no running) change a variable, it can be int, float or gameobject.
It will revert to previous setting when I press play?
All the best,
Joel
Re: Prefab changes variables back to previous version on play.
I just save a list of game objects.
so yeah maybe I just dont' understand but no I just want to save the link to gameobject, the variables on the card might change.
Last edited by BoBlond on Fri Aug 04, 2023 4:14 pm, edited 1 time in total.
Re: Prefab changes variables back to previous version on play.
Ah okay, I understand your issue now (this is quite different from the one in the thread you originally posted in).
By default collections of UnityEngine.Objects will be saved by reference and value. In your case you want to save them by value. To do this you can provide an ES3Settings object as a parameter when saving with it's referenceMode set to ES3.ReferenceMode.ByRef. I.e.
All the best,
Joel
By default collections of UnityEngine.Objects will be saved by reference and value. In your case you want to save them by value. To do this you can provide an ES3Settings object as a parameter when saving with it's referenceMode set to ES3.ReferenceMode.ByRef. I.e.
Code: Select all
var settings = new ES3Settings();
settings.referenceMode = ES3.ReferenceMode.ByRef;
ES3.Save("goReferences", gameObjectList, settings);
Joel
Re: Prefab changes variables back to previous version on play.
Thank you ! I'll try that now