Page 1 of 1
AutoSaveLoad issues
Posted: Wed Aug 12, 2020 6:20 pm
by jlhacode
Hi Tony,
My SaveSystem is composed of a JsonDataSerializer, DiskSavedGameDataStorer, and AutoSaveLoad components. I've found three issues that affect me:
1. I've found that I need to minimize twice to auto save on both Android and iOS.
2. Autoloading on mobile shows the first scene in the game briefly, then loads into the proper scene
3. Autoloading a saved file from the editor makes my game behave oddly (my mouse cursor disappears on load, i alt-tab to get the cursor back, but my clicks don't move the character anymore.)
Would you like a repro project sent to your email?
Re: AutoSaveLoad issues
Posted: Wed Aug 12, 2020 9:10 pm
by Tony Li
Hi,
No need for a repro project. The
Dialogue System Extras page has a patch fix in the "Updated for 2.2.9" foldout.
Re: AutoSaveLoad issues
Posted: Thu Aug 13, 2020 5:36 pm
by jlhacode
Hi Tony,
Thanks for the update! It fixed all my problems but one:
- Autoloading on mobile shows the first scene in the game briefly, then loads into the proper scene.
Do you have any recommendations for preventing this?
Re: AutoSaveLoad issues
Posted: Thu Aug 13, 2020 7:23 pm
by Tony Li
Yes. A few options:
1. Create a splash screen scene. Make this the first scene. Disable the AutoSaveLoad component. Use a TimedEvent component to enable AutoSaveLoad after a brief time (e.g., 0.5 second) and another TimedEvent to load the regular first scene after a longer time (e.g, 2 seconds). If AutoSaveLoad loads a saved game, the second TimedEvent won't have a chance to run, so it will load your saved game instead of your regular first scene.
2. Or create a splash screen as #1 but untick the AutoSaveLoad's Load On Start and use a small custom script to check if there's a saved game. If so, load it. Otherwise load the first screen. Example:
Code: Select all
if (SaveSystem.HasSavedGameInSlot(0)) SaveSystem.LoadFromSlot(0);
else SceneManager.LoadScene("My First Scene");
3. Or start your first scene with a fully black background that fades in when the scene starts. If there isn't a saved game, it will fade in normally into your first scene. If there is a saved game, it will load the saved game while the screen is still blacked out.
Re: AutoSaveLoad issues
Posted: Thu Aug 13, 2020 8:03 pm
by jlhacode
Hi Tony,
I'm trying to implement this solution:
2. Or create a splash screen as #1 but untick the AutoSaveLoad's Load On Start and use a small custom script to check if there's a saved game. If so, load it. Otherwise load the first screen. Example:
Code: Select all
if (SaveSystem.HasSavedGameInSlot(0)) SaveSystem.LoadFromSlot(0);
else SceneManager.LoadScene("My First Scene");
And I'm running into this issue again:
3. Autoloading a saved file from the editor makes my game behave oddly (my mouse cursor disappears on load, i alt-tab to get the cursor back, but my clicks don't move the character anymore.)
I believe there might be something causing the scene to recreate itself infinitely.
Re: AutoSaveLoad issues
Posted: Thu Aug 13, 2020 9:27 pm
by Tony Li
AutoSaveLoad has a "Don't Save In Scenes" list. Add the scene index of your splash screen. Your splash screen should have the Dialogue Manager components and Save System components. Make sure no other scenes have AutoSaveLoad.
Finally, inspect the SavedGameDataStorer component and delete the saved game(s). It sounds like maybe your game was saved in the splash screen scene. When the splash screen's AutoSaveLoad loads the saved game, it will load the splash screen, which will then see that it has an AutoSaveLoad, which loads the saved game, recursively forever like you suspect.
Re: AutoSaveLoad issues
Posted: Thu Aug 13, 2020 10:38 pm
by jlhacode
Unchecking "Don't Save In Scenes" and clearing out my saves prevented that infinite loop.
I've removed AutoSaveLoad from my other scenes, and I already had my DialogueManager in the splash screen scene, but I'm still running into this issue.
3. Autoloading a saved file from the editor makes my game behave oddly (my mouse cursor disappears on load, i alt-tab to get the cursor back, but my clicks don't move the character anymore.)
I was curious what the 2.2.9 patch changed, because I was running into this same issue on manual load and 2.2.9 fixed it. Now I'm just running into the issue when calling SaveSystem.LoadFromSlot(0)
Re: AutoSaveLoad issues
Posted: Thu Aug 13, 2020 11:12 pm
by Tony Li
Hi,
If you're talking about the AutoSaveLoad patch, it didn't change anything related to input.
Try inspecting the Dialogue Manager's Input Device Manager component and unticking "Control Cursor State". If this is unticked, the Dialogue System will not touch the cursor.
---
This is all that's in the AutoSaveLoad patch:
The SaveSystem class has two methods: SaveToSlot(#) and SaveToSlotImmediate(#).
SaveToSlot() takes a minimum of 2 frames:
- On the first frame, it invokes the saveStarted() event in case any custom code has registered for this event. Then it waits until the next frame, which gives time for UIs to appear/update if that's what the custom code does.
- On the second frame, it actually records the data and tells the SavedGameDataStorer to save it to permanent storage, with async saving allowed (i.e., it can take more than one frame to save if desired).
SaveToSlotImmediate(), on the other hand, runs immediately. It calls saveStarted(), then records the data and tells the SavedGameDataStorer to save it synchronously (i.e., in the same frame).
Prior to version 2.2.7, SaveToSlot() was
not asynchronous. It all ran in one frame.
The patch makes AutoSaveLoad call SaveToSlotImmediate(). Prior to the patch, AutoSaveLoad called SaveToSlot(#). But when the game is quitting, it only has one frame to complete the save. Since version 2.2.7 made SaveToSlot() asynchronous, it didn't actually have a change to save before the game quit.
Re: AutoSaveLoad issues
Posted: Fri Aug 14, 2020 1:21 am
by jlhacode
Everything worked perfectly, thanks again Tony!
Re: AutoSaveLoad issues
Posted: Fri Aug 14, 2020 9:47 am
by Tony Li
Glad to help!