Hi Tony, our game is a narrative game that doesn't involves complicate data (at least for now).
So I'm thinking to use the PersistentDataManager.GetSaveData() and ApplySaveData() to save variables, I'm wondering what is the best way to achieve this.
My thoughts, I add a static Item in dialogue editor, for instance, name it slot_A, than whenever player hit the save button, I use GetSaveData() to gather all the variables into a string, then manually update that string to the slot_A value.
Next time when the player wants to load from those variables, I use DialogueLua.GetItemField() to retrieve the save data string and ApplySaveData().
Does above logic makes any sense? or do I have any other simple way to save/load variables? tks
About using save data in dialogue system
Re: About using save data in dialogue system
Hi,
That won't save anything to persistent storage. Consider using PlayerPrefs instead. Here are two methods to save and load the variables:
That won't save anything to persistent storage. Consider using PlayerPrefs instead. Here are two methods to save and load the variables:
Code: Select all
public void SaveGame() {
PlayerPrefs.SetString("SavedGame", PersistentDataManager.GetSaveData());
}
public void LoadGame() {
if (PlayerPrefs.HasKey("SavedGame")){
PersistentDataManager.ApplySaveData(PlayerPrefs.GetString("SavedGame"));
} else {
DialogueManager.ResetDatabase();
}
}