Page 1 of 1
Saving Variable without Dont Destroy On Load
Posted: Sun Jul 11, 2021 3:44 pm
by wlchfl5359
Hi, i want to save Dialogue Variable without Dont Destroy On Load. is it possible?
If i add component 'Save System', i can save Variable, but it says Dialogue Manager will be 'Dont Destroy On Load'.
Is there any different way to save Variable without that??
Thank you.
Re: Saving Variable without Dont Destroy On Load
Posted: Sun Jul 11, 2021 5:33 pm
by Tony Li
Hi,
Yes, there are two ways:
1. Put the Save System component on a different GameObject. That GameObject will be Dont Destroy On Load. Add a Dialogue System Saver component to the Dialogue Manager.
2. Or call PersistentDataManager.GetSaveData(). This will return a string containing the current variable values. To restore those values back into the Dialogue System, pass them to PersistentDataManager.ApplySaveData().
Re: Saving Variable without Dont Destroy On Load
Posted: Mon Jul 12, 2021 12:19 am
by wlchfl5359
Thank you for reply.
I tried a way No.1 but it doesn't save variable.
I created new object and put Save System component, and i put Dialogue System Saver component to Dialogue Manager Object. But it didn't save any variable
Re: Saving Variable without Dont Destroy On Load
Posted: Mon Jul 12, 2021 8:52 am
by Tony Li
From your other thread, it sounds like maybe you are now using the default setting: Don't Destroy On Load. If so, that's the easiest way to make variable values stay the same across scene changes.
Otherwise, if you use a Save System GameObject, you must
change scenes using one of these techniques.
Re: Saving Variable without Dont Destroy On Load
Posted: Mon Jul 12, 2021 10:24 am
by wlchfl5359
I'm using different asset to change scene.
So Should i use the way No.2 'using code : PersistentDataManager.ApplySaveData().'?
Thank you for reply.
Re: Saving Variable without Dont Destroy On Load
Posted: Mon Jul 12, 2021 12:54 pm
by Tony Li
Yes, you can either use PersistentDataManager.SaveGameData() before leaving the old scene and ApplyGameData() after entering the new scene.
Or, if you want to use the full save system, call these lines before leaving the old scene:
Code: Select all
PixelCrushers.SaveSystem.RecordSavedGameData();
PixelCrushers.SaveSystem.BeforeSceneChange();
and call this line after entering the new scene:
Code: Select all
PixelCrushers.SaveSystem.ApplySavedGameData();