Hi,
I use "SaveSystem.LoadFromSlot(1);"
and in the loaded scene want to do operations on DS Variables in Unity Start() method.
The variable is for ex. "MyVar" with initial to false.
in the game MyVar is changed to true with
DialogueLua.SetVariable("MyVar", true);
then saved, when next time game is DS Loaded and in the loaded scene from save, checking MyVar in Start() with
DialogueLua.GetVariable("MyVar").asBool > get false
But with afterwards method inside game gets true.
So my guess is in Start() variables are not Loaded from save, but some script updates it later.
Am I right? if so what is the workaround?
Get Variables in Unity Start() method
Get Variables in Unity Start() method
Last edited by Poliman on Mon Jul 31, 2023 1:54 am, edited 1 time in total.
Re: System hangs on conversation START
Hi,
Have you set up the full save system? The Dialogue System Saver will restore the DS variable values as soon as the saved game is loaded.
Other savers, however, may not be restored yet when the Start() method runs. To know when all of the savers have been restored, hook into the C# event SaveSystem.saveDataApplied. Example:
Have you set up the full save system? The Dialogue System Saver will restore the DS variable values as soon as the saved game is loaded.
Other savers, however, may not be restored yet when the Start() method runs. To know when all of the savers have been restored, hook into the C# event SaveSystem.saveDataApplied. Example:
Code: Select all
SaveSystem.saveDataApplied += OnSaveDataApplied;
SaveSystem.LoadFromSlot(1);
...
void OnSaveDataApplied()
{
SaveSystem.saveDataApplied -= OnSaveDataApplied; //[EDIT: Fixed typo]
// At this point I know that all saved data has been restored.
}
Re: Get Variables in Unity Start() method
Well I think all is setup according to help
I use PlayerPrefs data storer
Debug log
_ in Start () GetVariable:False _
_ end of Start method _
_ Update 1 frame _
_ OnSaveDataApplied _
_ in OnSaveDataApplied GetVariable:True _
So after one frame event is called, is it ok then and i cannot set it up to make it work in Start()?
Next qtn why do You use "SaveSystem.saveDataApplied += OnSaveDataApplied;" inside OnSaveDataApplied?
I use PlayerPrefs data storer
Debug log
_ in Start () GetVariable:False _
_ end of Start method _
_ Update 1 frame _
_ OnSaveDataApplied _
_ in OnSaveDataApplied GetVariable:True _
So after one frame event is called, is it ok then and i cannot set it up to make it work in Start()?
Next qtn why do You use "SaveSystem.saveDataApplied += OnSaveDataApplied;" inside OnSaveDataApplied?
Re: Get Variables in Unity Start() method
Hi,
sorry, "+=" was a typo. I fixed it to "-=" to unhook from SaveSystem.saveDataApplied.
If your Save System component's Frames To Wait Before Apply Data is 1, then waiting 1 frame may work. However, it's better to use SaveSystem.saveDataApplied.
sorry, "+=" was a typo. I fixed it to "-=" to unhook from SaveSystem.saveDataApplied.
If your Save System component's Frames To Wait Before Apply Data is 1, then waiting 1 frame may work. However, it's better to use SaveSystem.saveDataApplied.