Page 1 of 2

How to create a saving and loading system?

Posted: Fri Dec 30, 2016 10:50 am
by harumin
How to create a saving and loading system visual novel style? I'm still kinda new to unity and the dialogue system and I am trying to make a visual novel using 3D models. How do I save and load states and dialogues from the database?

Re: How to create a saving and loading system?

Posted: Fri Dec 30, 2016 3:17 pm
by Tony Li
Hi!

You can use the Visual Novel Framework on the Dialogue System Extras page. It includes saving and loading. It's the third download button under EXTRAS. Since it was written for Unity 5.2+, it may report "deprecated API" warnings in higher versions of Unity until I have a chance to update it. But it will work fine anyway.

Otherwise, if you just want to save and load the Dialogue System's data in your own scripts, use PersistentDataManager:

Code: Select all

// Save the Dialogue System's current state to a string:
string savedData = PersistentDataManager.GetSaveData();

// Restore the Dialogue System's state using a string:
PersistentDataManager.ApplySaveData(savedData); 
You can read more about the save system here: Save System.

There are also equivalent actions in third-party supported visual scripting assets such as PlayMaker and ICode.

If you have any questions about it, please let me know.

Re: How to create a saving and loading system?

Posted: Sun Jan 01, 2017 8:55 am
by harumin
So I tried following the visual novel framework's save helper on a simple loading and saving and restart button. When I tried to load the game or even restart the game the warning says : Dialogue System : Conversation triggered on NPC, but another conversation is already active.

Re: How to create a saving and loading system?

Posted: Sun Jan 01, 2017 10:06 am
by Tony Li
Hi,
harumin wrote:So I tried following the visual novel framework's save helper on a simple loading and saving and restart button. When I tried to load the game or even restart the game the warning says : Dialogue System : Conversation triggered on NPC, but another conversation is already active.
The Visual Novel Framework's SaveHelper is somewhat specific to the Visual Novel Framework. It assumes one conversation is always running, and it saves the player's place in the conversation. It probably won't work as well if you use it outside the context of the Visual Novel Framework. To test it out, add these scenes to your build settings: Dialogue System Extras > Visual Novel Framework > Example > Example Start and Example Gameplay. And then play Example Start.

If you're looking for a general purpose menu framework for saving and loading, use the Dialogue System Menu Framework, which is the first button under EXTRAS.

If you don't need a complete menu framework with start menu, pause menu, etc., I suggest skimming over the options in the Save System section of the manual -- or just ask here. I'm happy to answer any questions! A more lightweight, but still component-driven, option is GameSaver. Or, to get closer to the metal, use LevelManager or PersistentDataManager. You can find Save System Quick Start steps here that describe how to use these.

Saving and loading is one of the most complicated parts of game development since it deals with serialization of game data, restoring game state, etc. If you have any questions about it, or if you get stuck anywhere, just let me know. I'm here to help!

Re: How to create a saving and loading system?

Posted: Mon Jan 02, 2017 1:46 am
by harumin
GameSaver worked! I also used RememberCurrentDialogueEntry script to keep the current dialogue and resume when loaded but still having warning Dialogue System : Conversation triggered on NPC, but another conversation is already active when loaded. Also, is it possible to create a logging system where you could see the previous entries on dialogues?

Re: How to create a saving and loading system?

Posted: Mon Jan 02, 2017 9:30 am
by Tony Li
Hi,
harumin wrote:I also used RememberCurrentDialogueEntry script to keep the current dialogue and resume when loaded but still having warning Dialogue System : Conversation triggered on NPC, but another conversation is already active when loaded.
You probably have a Conversation Trigger set to OnStart, in which case you might want to ignore the warning and leave the Conversation Trigger in place. This way, if RememberCurrentDialogueEntry doesn't restart a conversation automatically, the Conversation Trigger (OnStart) will ensure that a conversation is running.
harumin wrote:Also, is it possible to create a logging system where you could see the previous entries on dialogues?
On the Dialogue System Extras page, the fourth download button in the UIs section is "Conversation Log Dialogue UI". This is a logging system for previous dialogue entries.

In the Misc section, there's a "Backtracking Example" that lets you actually move backward in conversations (rewind) if that's what you're looking for.

Re: How to create a saving and loading system?

Posted: Mon Mar 13, 2017 10:56 am
by harumin
How to add a date and time on Gamesaver slots? I made five buttons each for loading and saving and I want to display the time and date they saved on the button text like SaveHelper on Visual Novel Framework. SaveHelper doesn't seem to work for me but GameSaver does. I want to add that feature to game saver. Please help.

Re: How to create a saving and loading system?

Posted: Mon Mar 13, 2017 2:24 pm
by Tony Li
Hi,

Hi,

I suggest saving it to PlayerPrefs. For example, let's say you save your game like this:

Code: Select all

GameSaver.SaveGame(1); // Save in slot #1.     
You can also save information about the game like this:

Code: Select all

GameSaver.SaveGame(1); // Save in slot #1.
PlayerPrefs.SetString("Slot_1", "Saved: " + DateTime.Now); // Also save date/time summary.    
To get the date/time info, do something like:

Code: Select all

var summary = PlayerPrefs.GetString("Slot_1"); // Get the summary.
myLoadGameButton.GetComponentInChildren<Text>().text = summary; // Set the load game button's label to the summary.  
If that doesn't take care of it for you, can you describe what's going wrong with SaveHelper? Maybe we can get it working.

Re: How to create a saving and loading system?

Posted: Tue Mar 14, 2017 8:06 am
by harumin
SaveHelper is now working. Though, I had to make another project . Weird.

Re: How to create a saving and loading system?

Posted: Tue Mar 14, 2017 12:48 pm
by Tony Li
Well I'm glad it's working at least. If it gives you any trouble, let me know.