Page 2 of 2

Re: Simple Save and Load from SAV File

Posted: Wed Aug 14, 2024 11:42 am
by xyztankman
Ahh got it to work! I had to check "Skip Apply Data After Frames If Apply Immediate" and it started loading the games correctly. I'll do a bit more testing but I think it's working now after 5 load attempts.

Re: Simple Save and Load from SAV File

Posted: Wed Aug 14, 2024 11:46 am
by Tony Li
Hi -- you beat me to it. :-) I was writing up these suggestions:


I recommend using the default values for the DialogueSystemSaver component (Save Across Scene Changes & Skip Apply Data After Frames If Apply Immediate both ticked).

Also, saving and loading may take more than one frame. (If you must absolutely save in one frame, such as when exiting the application, call SaveSystem.SaveToSlotImmediate(#).)

To know when the load is complete, use the C# event SaveSystem.loadEnded. For example:

Code: Select all

SaveSystem.loadEnded += OnLoadEnded;
SaveSystem.LoadFromSlot(slotNumber);
...
void OnLoadEnded()
{
    SaveSystem.loadEnded -= OnLoadEnded;
    SceneHubContinue(); ...

Re: Simple Save and Load from SAV File

Posted: Wed Aug 14, 2024 12:47 pm
by xyztankman
Perfect, thanks for the suggestions! I'm trying to do a visual novel style system with a realtime clock that saves every in-game hour.

The "hub" that all the other scenes stem from keeps the time and the others have a separate time instance, so I didn't want them to save on scene change.

Is SaveToSlotImmediate the recommended way to save? I set it to only save in-game hour to an autosave and manual save buttons to save to individual slots.

Also if I choose custom data path for the disk saver, how would I set it to have a separate folder inside the gamefolder? Like Game/Save/save_5.dat

Re: Simple Save and Load from SAV File

Posted: Wed Aug 14, 2024 3:08 pm
by Tony Li
Hi,

SaveToSlot() is the recommended way to save, but either is fine unless you're saving while exiting the application (in which case use SaveToSlotImmediate(). SaveToSlot() has these two differences:

1. It waits 1 frame before starting the save process to allow UIs to update (e.g., show a "save in progress" icon).

2. It allows the SavedGameDataStorer to take as many frames as it needs to store the saved game data.

In contrast, SaveToSlotImmediate():

1. Does not wait 1 frame.

2. Tells the SavedGameDataStorer to save immediately, not taking any extra frames.

If you choose custom data path, you can specify it in the Custom Path field or set customPath in your own code. Example:

Code: Select all

SaveSystem.instance.GetComponent<DiskSavedGameDataStorer>().customPath = $"{Application.persistentDataPath}/Save";

Re: Simple Save and Load from SAV File

Posted: Wed Aug 14, 2024 5:43 pm
by xyztankman
Perfect, working just as intended, I'll stick with SaveToSlot then since I don't want to save on exit. Thanks a bunch Tony!

Re: Simple Save and Load from SAV File

Posted: Wed Aug 14, 2024 6:43 pm
by Tony Li
Happy to help!