How to know loading save is finished

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
windwalking
Posts: 6
Joined: Tue Mar 26, 2024 6:31 am

How to know loading save is finished

Post by windwalking »

Hello!

Currently, I have an issue with the Save system. I can load and save my variables just fine. However when trying to rely on variables from the save file on Start functions, the save system did not finish loading and I only get the default values. Is there a way to make save system finish loading before everything else? Alternatively is there a way to know if the save system finished loading?
User avatar
Tony Li
Posts: 22093
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to know loading save is finished

Post by Tony Li »

Hi,

Yes, you can use SaveSystem.saveDataApplied. Example:

Code: Select all

using PixelCrushers; // Put at top of script.
...
SaveSystem.saveDataApplied += OnSaveDataApplied;
SaveSystem.LoadFromSlot(0);
...
void OnSaveDataApplied()
{
    SaveSystem.saveDataApplied -= OnSaveDataApplied;
    Debug.Log("Save data was applied.");
}
BTW, if you've set a Dialogue System Trigger to OnStart, you can change its Trigger dropdown to OnSaveDataApplied to tell it to wait for the save data to be applied before starting. If it's a regular scene start (e.g., entering play mode) and it's not applying save data, then it will act like OnStart.
Post Reply