Page 1 of 1

Dialogue System variable values not being saved.

Posted: Fri Dec 31, 2021 5:42 pm
by Vomdrache
Hey Tony,

Hope you've been having a good holiday.

I'm currently having some issues with database variables - pretty simple setup with 4 boolean variables. I have Dialogue System Saver on my dialogue system object.

The variables are correctly stored when changing scenes - I see the values correctly being saved by pressing "Show" on the PlayerPrefsSavedGameDataStorer.

However, once I manually save the game with SaveSystem.SaveToSlot(0) - all of the variables are reverted back to their original values.

Any idea what might be causing these variables to not correctly save?

- Frank

Re: Dialogue System variable values not being saved.

Posted: Fri Dec 31, 2021 8:03 pm
by Tony Li
Hi Frank,

Do the variables go back to their original values immediately after calling SaveSystem.SaveToSlot(0)? Or does something happen after that, such as calling some other C# code or stopping and restarting play mode?

Do the variables have their saved values if you load the game in slot 0?

Re: Dialogue System variable values not being saved.

Posted: Sat Jan 01, 2022 11:16 am
by Vomdrache
I have PlayerPrefsSavedGameDataStorer set to debug, the first action that occurs when selecting "return to title" from the options menu is the SaveToSlot() method. The output is an immediate json with all the values being reverted.

The code running after is: PixelCrushers.SaveSystem.RestartGame("MainMenu").

Re: Dialogue System variable values not being saved.

Posted: Sat Jan 01, 2022 12:00 pm
by Tony Li
SaveSystem.RestartGame() will reset all data in memory (save data and Dialogue System variables/quests), and then load a starting gameplay scene.

Re: Dialogue System variable values not being saved.

Posted: Sat Jan 01, 2022 12:20 pm
by Vomdrache
Yeah, commenting out that line worked.

I thought the json was separate from the cached save data that is being cleared?

I had no issues with it retaining all other data outside of these variables. What would be the proper solution to return to a main menu and essentially "restart" the game after SaveToSlot() is called?

Re: Dialogue System variable values not being saved.

Posted: Sat Jan 01, 2022 2:47 pm
by Tony Li
The data that PlayerPrefsSavedGameDataStorer stores in persistent storage is different from the data that is cached in memory.

SaveSystem.RestartGame() (or SaveSystem.ResetGameState() if you don't want to load a scene) only clears the data that is cached in memory.

Is it possible that you're calling SaveSystem.SaveToSlot(0) again after calling SaveSystem.RestartGame()?

Re: Dialogue System variable values not being saved.

Posted: Sat Jan 01, 2022 3:20 pm
by Vomdrache
I've been digging around, but the setup is pretty straight forward.
  • SaveToSlot()
  • RestartGame("MainMenu")
I have SaveSystem.saveDataApplied that slaves to slot as well, however, I created a scene index black list so that it does not fire off on scenes such as the MainMenu.

To be sure, I removed this and there were no changes.

When selecting debug, it only outputs the json result once. For extra measure I also added a Debug.Log() in the RecordSavedGameData() method, and this also only fires off once.

Re: Dialogue System variable values not being saved.

Posted: Sat Jan 01, 2022 4:41 pm
by Tony Li
At what point are the Dialogue System variables reset? After calling SaveSystem.RestartGame()? If so, that's exactly what should be expected.

Is your Dialogue Manager configured with the default Don't Destroy On Load value? If you're not allowing the Dialogue Manager to survive scene changes, then it will lose its variables when you change scenes.

If that doesn't help, please feel free to send a reproduction project to tony (at) pixelcrushers.com

Re: Dialogue System variable values not being saved.

Posted: Mon Jan 03, 2022 2:46 pm
by Vomdrache
For the time being, I've removed the RestartGame line and just have the scene changing to the main menu. From there, new game will wipe the data anyways, and continue will load the proper stored data.

Re: Dialogue System variable values not being saved.

Posted: Mon Jan 03, 2022 4:07 pm
by Tony Li
Sounds good. That'll get the job done.