Saving Dialogue Database

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
pizzadelivery3
Posts: 11
Joined: Thu Jun 06, 2024 9:37 pm

Saving Dialogue Database

Post by pizzadelivery3 »

Hello. I specifically only want to save and load a dialogue database (I have another save system for most everything else). I was wondering what the easiest way would be to save and load by using an onclick() event from a button. Thanks
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving Dialogue Database

Post by Tony Li »

Hi,

To save and load only the database in C#, please see Dialogue Database-Only Save. It one line of code each for save and load, which puts the dialogue database save data in a string. You can include that string in your own save system if youwant.

To save and load to persistent storage (e.g., disk or PlayerPrefs) using a UI Button, you'll need to set up a minimal version of the save system:

1. Add these components to the Dialogue Manager: SaveSystem, DialogueSystemSaver, JsonDataSerializer, and PlayerPrefsSavedGameDataStorer or DiskSavedGameDataStorer.

2. UNtick the SaveSystem component's Save Current Scene.

3. Set the DialogueSystemSaver's Key to a unique value such as "ds".

4. Add a SaveSystemMethods component to your UI Button. Configure the Button's OnClick() to call SaveSystemMethods.SaveToSlot or LoadFromSlot.
pizzadelivery3
Posts: 11
Joined: Thu Jun 06, 2024 9:37 pm

Re: Saving Dialogue Database

Post by pizzadelivery3 »

it appears there is no option in the SaveSystemMethod for "SaveToSlot" only "LoadToSlot". There is only "SaveSlot". Not sure if this is the method that saves or if I'm missing it somehow.
pizzadelivery3
Posts: 11
Joined: Thu Jun 06, 2024 9:37 pm

Re: Saving Dialogue Database

Post by pizzadelivery3 »

Also is there a way to call the "SaveToSlot" or "LoadFromSlot" methods in a script? I have an auto save function so I want to be able to save and load with that alongside an OnClick() event with a button.
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving Dialogue Database

Post by Tony Li »

Hi,

If you're using the save system, you can call SaveSystem.SaveToSlot() and LoadFromSlot() in a script.

However, if you only want to save the dialogue database from a script, you can use the two methods in the link above (PersistentDataManager.GetSaveData() and ApplySaveData()).
pizzadelivery3
Posts: 11
Joined: Thu Jun 06, 2024 9:37 pm

Re: Saving Dialogue Database

Post by pizzadelivery3 »

Hi,

When I load a saved state from a scene I've already been in before during runtime saving and loading the dialogue database seems to work no problem. If I save the dialogue database in a scene and exit runtime and then go back into play mode and load into a scene and attempt to load the saved dialogue database from that scene it appears the saved state does not persist.
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving Dialogue Database

Post by Tony Li »

How are you saving and loading? PersistentDataManager.GetSaveData() and ApplySaveData()?
pizzadelivery3
Posts: 11
Joined: Thu Jun 06, 2024 9:37 pm

Re: Saving Dialogue Database

Post by pizzadelivery3 »

I'm still using the OnClick() event for SaveSystemMethods.SaveSlot() to save and SaveSystemMethods.LoadFromSlot() to load. Is there a way to use PersistentDataManager.GetSaveData() and ApplySaveData() for an OnClickEvent()? If so what component needs to be added to the button to do this as I don't see either option in the Save System Methods
pizzadelivery3
Posts: 11
Joined: Thu Jun 06, 2024 9:37 pm

Re: Saving Dialogue Database

Post by pizzadelivery3 »

Ah I see the button in a different scene wasn't hooked up with the proper saving and loading methods mentioned earlier. Everythings looking good now. Thanks for all the help!
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Saving Dialogue Database

Post by Tony Li »

Glad to help!
Post Reply