Dialogue System variable values not being saved.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Vomdrache
Posts: 21
Joined: Wed Aug 18, 2021 1:00 pm

Dialogue System variable values not being saved.

Post 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
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System variable values not being saved.

Post 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?
Vomdrache
Posts: 21
Joined: Wed Aug 18, 2021 1:00 pm

Re: Dialogue System variable values not being saved.

Post 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").
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System variable values not being saved.

Post 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.
Vomdrache
Posts: 21
Joined: Wed Aug 18, 2021 1:00 pm

Re: Dialogue System variable values not being saved.

Post 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?
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System variable values not being saved.

Post 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()?
Vomdrache
Posts: 21
Joined: Wed Aug 18, 2021 1:00 pm

Re: Dialogue System variable values not being saved.

Post 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.
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System variable values not being saved.

Post 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
Vomdrache
Posts: 21
Joined: Wed Aug 18, 2021 1:00 pm

Re: Dialogue System variable values not being saved.

Post 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.
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System variable values not being saved.

Post by Tony Li »

Sounds good. That'll get the job done.
Post Reply