Hello
I am totaly lost with the save system :c i just want to save and load simple variables across conversations but i can't figure out how it works
I'm using the GameSaver component for saving the variables in the conversations and made two simple methods for calling SaveGame() and LoadGame() from the GameSaver component. During the conversation i use SendMessage(NameOfTheMethod,,DialogueManager) in the Sequence thing, and there are no warnings. BUT each time i restart the conversation, the variable are reset to their initial state (i tracked these variable during the conversation and the values did change).
if i did something wrong what is the correct way for saving/loading these variable easily ?
thanks
Saving or loading variable in conversation
Re: Saving or loading variable in conversation
Hi,
Are these Dialogue System variables, as in variables that you've added to your dialogue database in the Dialogue Editor's Variable section? If so, and if you don't want to use the whole save system, then configure your SaveGame() and LoadSave() similarly to this:
If you need to save your own variables that you've defined in a C# script, you can use the full save system. In this case, write a custom saver.
Are these Dialogue System variables, as in variables that you've added to your dialogue database in the Dialogue Editor's Variable section? If so, and if you don't want to use the whole save system, then configure your SaveGame() and LoadSave() similarly to this:
Code: Select all
void SaveGame()
{
string savedVariables = PixelCrushers.DialogueSystem.PersistentDataManager.GetSaveData();
// (Now you need to save the string. For example:)
PlayerPrefs.SetString("Variables", savedVariables);
}
void LoadGame()
{
if (PlayerPrefs.HasKey("Variables"))
{
string savedVariables = PlayerPrefs.GetString("Variables");
PixelCrushers.DialogueSystem.PersistentDataManager.ApplySaveData(savedVariables);
}
else
{ // (We don't have any save data, so just reset to initial state:)
PixelCrushers.DialogueSystem.DialogueManager.ResetDatabase();
}
}
If you need to save your own variables that you've defined in a C# script, you can use the full save system. In this case, write a custom saver.
Re: Saving or loading variable in conversation
Thanks a lot for your help !!! it works !
Re: Saving or loading variable in conversation
Glad to help!