Page 1 of 1

Save Quest Data [Solved]

Posted: Mon Apr 20, 2020 11:06 pm
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.

Re: Save Quest Data

Posted: Tue Apr 21, 2020 9:30 am
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.

Re: Save Quest Data

Posted: Tue Apr 21, 2020 7:34 pm
by thereaper43
Thanks a lot, Tony!

Went through the Dialogue System docs and found a solution.

Re: Save Quest Data [Solved]

Posted: Tue Apr 21, 2020 8:50 pm
by Tony Li
Great! Glad to help.