Save Quest Data [Solved]

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
thereaper43
Posts: 2
Joined: Mon Apr 20, 2020 10:42 pm

Save Quest Data [Solved]

Post by thereaper43 »

I'm following along with the GameDevTV Unity RPG course and just want to save and load quest data. Saving and loading works when switching scenes, but when I quit the unity editor and play/load it doesn't load the quest data.
Attachments
Capture.PNG
Capture.PNG (111.25 KiB) Viewed 270 times
Last edited by thereaper43 on Tue Apr 21, 2020 7:35 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save Quest Data

Post by Tony Li »

Hi,

The end of your SaveData method gets the data from the Dialogue System:

Code: Select all

s = PixelCrushers.DialogueSystem.PersistentDataManager.GetSaveData();
but it doesn't save it anywhere. I'm not familiar with that RPG tutorial, but you might be able to do something like this:

Code: Select all

public void Save(string saveFile)
{
    Dictionary<string, object> state = LoadFile(saveFile);
    CaptureState(state);
    s = PixelCrushers.DialogueSystem.PersistentDataManager.GetSaveData();
    state.Add("DialogueSystem", s);
    SaveFile(saveFile, state);
}

public IEnumerator Load(string saveFile)
{
    int buildIndex = SceneManager.GetActiveScene().buildIndex;
    yield return SceneManager.LoadSceneAsync(buildIndex);
    RestoreState(LoadFile(saveFile));
    s = state["DialogueSystem"]; //<-- DEPENDS ON state CONTAINING VALID DATA & KEY NAMED "DialogueSystem".
    PixelCrushers.DialogueSystem.PersistentDataManager.ApplySaveData(s);
}
BTW, the Dialogue System comes with a very robust save system.
thereaper43
Posts: 2
Joined: Mon Apr 20, 2020 10:42 pm

Re: Save Quest Data

Post by thereaper43 »

Thanks a lot, Tony!

Went through the Dialogue System docs and found a solution.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save Quest Data [Solved]

Post by Tony Li »

Great! Glad to help.
Post Reply