Properly Deleting Dialogue Save Data in Runtime?

Announcements, support questions, and discussion for the Dialogue System.
sebjschindler
Posts: 16
Joined: Sun Nov 17, 2019 12:07 am

Properly Deleting Dialogue Save Data in Runtime?

Post by sebjschindler »

Hi,

In one of my projects, I'm having difficulties deleting/resetting all dialogue-related data during runtime.
I have a "Delete Save Data" button in my project's main menu that calls DialogueManager.ResetDatabase and PersistentDataManager.Reset along with a .txt file containing the contents of PersistentDataManager.GetSaveData. Saving/loading data is fine both in runtime and out of playmode in-editor. Resetting/deleting this dialogue data does not work in runtime, yet it does out of playmode in-editor. Is there a specific way I should be resetting/deleting these values? Does the SG Dialogue Manager object play a role in this? Any direction would be highly appreciated, thank you!
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Properly Deleting Dialogue Save Data in Runtime?

Post by Tony Li »

Hi,

Are you using the full save system? If so:
  • You'll want to call SaveSystem.ResetGameState(). This will reset the Save System's in-memory save data cache. If your Dialogue Manager has a Dialogue System Saver component, it will also reset the Dialogue System's runtime data.
  • To delete saved game(s), call SaveSystem.storer.DeleteSavedGameData().
If you're not using the full save system, then by "in runtime" do you mean a build? You only need to call DialogueManager.ResetDatabase() to reset the in-memory runtime data and then delete your .txt file. If that doesn't work in a build, make sure your code is correctly deleting the .txt file.
sebjschindler
Posts: 16
Joined: Sun Nov 17, 2019 12:07 am

Re: Properly Deleting Dialogue Save Data in Runtime?

Post by sebjschindler »

Hi,

I am not using the full save system, and yes by "in runtime" I am referring to a build.
I forgot to mention this earlier, but one oddity is that if I delete the data in a build, close the game, re-open it, and delete the data again, it's behaving as intended. This is strange since it appears I am following the right resetting procedure (via DialogueManager.ResetDatabase() + deleting the .txt file properly), yet nothing substantial happens until I relaunch the game and try deleting then. I know DialogueManager.ResetDatabase() can take a DatabaseResetOption - would that help with anything? Thanks for the quick reply, btw!
sebjschindler
Posts: 16
Joined: Sun Nov 17, 2019 12:07 am

Re: Properly Deleting Dialogue Save Data in Runtime?

Post by sebjschindler »

Oh, and as a follow-up question: Are there any required objects that need to be present in the scene for the DialogueManager to reset? I would assume no due to it being a static property, but any light you can shed would help!
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Properly Deleting Dialogue Save Data in Runtime?

Post by Tony Li »

Hi,

No objects need to be in the scene. However, keep in mind that the Dialogue Manager GameObject survives scene changes by default. During play, the first Dialogue Manager to appear will survive scene changes and replace Dialogue Managers in subsequently-loaded scenes. This is often the big difference between testing an individual scene in the editor's play mode versus testing the entire build. When you play a build, it plays from the first scene in your build settings list.

What data do not appear to be reset?

It doesn't sound like you need to specify a DatabaseResetOption for DialogueManager.ResetDatabase(). The method resets the runtime values of the dialogue database -- variables, quest states, and the like.
sebjschindler
Posts: 16
Joined: Sun Nov 17, 2019 12:07 am

Re: Properly Deleting Dialogue Save Data in Runtime?

Post by sebjschindler »

Hi,

The only data that appears to not reset properly are those modified by Get/SetStatus. I modify these values both within the Conversations tab in the Dialogue Database as well as through my own script. (i.e. GetStatus(Actor["Player"], Actor["Dude"]) == "Met")

In regards to the Dialogue Manager GO being a persistent object across scenes, I currently do not have it set to destroy when returning to the main menu - should I be doing that? The first scene the Dialogue Manager GO exists in is said main menu, but there are other Dialogue Manager GOs in other scenes. Would it be beneficial to only have one spot in the game where the Dialogue Manager GO should exist?
sebjschindler
Posts: 16
Joined: Sun Nov 17, 2019 12:07 am

Re: Properly Deleting Dialogue Save Data in Runtime?

Post by sebjschindler »

And as another follow-up question: does the Dialogue Manager GO need to be refreshed or something similar whenever I try deleting dialogue data?
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Properly Deleting Dialogue Save Data in Runtime?

Post by Tony Li »

Hi,
sebjschindler wrote: Thu Jul 08, 2021 10:57 pmThe only data that appears to not reset properly are those modified by Get/SetStatus. I modify these values both within the Conversations tab in the Dialogue Database as well as through my own script. (i.e. GetStatus(Actor["Player"], Actor["Dude"]) == "Met")
That's a bug! The reset neglected to reset the status and relationship tables. Here's a patch:

DS_DialogueLuaPatch_2021-07-08.unitypackage

This fix will also be in version 2.2.19.
sebjschindler wrote: Thu Jul 08, 2021 10:57 pmIn regards to the Dialogue Manager GO being a persistent object across scenes, I currently do not have it set to destroy when returning to the main menu - should I be doing that? The first scene the Dialogue Manager GO exists in is said main menu, but there are other Dialogue Manager GOs in other scenes. Would it be beneficial to only have one spot in the game where the Dialogue Manager GO should exist?
No, it's much more convenient for playtesting to have a Dialogue Manager GO in whatever scenes you want to playtest. Use the default values (Don't Destroy On Load). Just keep in mind that, in builds and when you playtest from the main menu, the Dialogue Manager GO in the main menu will survive scene changes.
sebjschindler wrote: Thu Jul 08, 2021 11:20 pm And as another follow-up question: does the Dialogue Manager GO need to be refreshed or something similar whenever I try deleting dialogue data?
No. It takes care of that automatically.
sebjschindler
Posts: 16
Joined: Sun Nov 17, 2019 12:07 am

Re: Properly Deleting Dialogue Save Data in Runtime?

Post by sebjschindler »

Oh wow, that's actually a bug? I'm glad my situation here helped bring it to light! I'll download this package first thing tomorrow and let you know how it goes. Though that said, this is my first time updating the Dialogue Manager since I bought it back in 2019 - are there any specific steps to importing this package?
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Properly Deleting Dialogue Save Data in Runtime?

Post by Tony Li »

I tested the patch with the latest version (2.2.18). Back up your project before importing the patch, just to be on the safe side.

If you experience an issue running the patch on an older version, consider updating. If you update, review the release notes. You can search for "Changed" to identify any important changes that aren't just bug fixes or additions.
Post Reply