How to make a save game and load game?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
HaiiroMukuro
Posts: 80
Joined: Sun Jul 17, 2016 3:38 pm

How to make a save game and load game?

Post by HaiiroMukuro »

Good day! :)
Is there a guide for making a save game and load game for dialogue system?
It seems like I'm lost. :lol:
The save and load game are in a panel which contains 10 buttons, and those buttons where you can save the game and load the game.
I'm also trying to modify the in feature demo script. I replace the clear game save to Settings, then the save and load game opens a panel having 10 buttons.
Thank you and have a great day! :D
User avatar
Tony Li
Posts: 21079
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to make a save game and load game?

Post by Tony Li »

You can download the Menu Framework from the Dialogue System Extras page. It's the first download button under EXTRAS. This provides an entire menu framework, including a title menu, in-game pause menu, and save/load game menus.

I recommend not using FeatureDemo.cs. This script was designed just to drive the demo scenes. You can use it as a base, but I think there are better solution now, such as the Menu Framework above.

If you don't want to do that, try these steps:

1. Add a GameSaver and a LevelManager to your Dialogue Manager.

2. Set up a Unity UI button to save a slot. Set the UI button's OnClick() event to GameSaver.SaveSlot, and specify a slot number.

3. Set up a Unity UI button to load a slot. Set the UI button's OnClick() event to GameSaver.LoadSlot, and specify a slot number.
HaiiroMukuro
Posts: 80
Joined: Sun Jul 17, 2016 3:38 pm

Re: How to make a save game and load game?

Post by HaiiroMukuro »

Instead of using the feature demo, I tried what you recommend which is putting a game saver and level manager in dialogue manager and it work.
Now I understand, thanks to your help. :)
But I still have a question.
Does it save and load variables?
User avatar
Tony Li
Posts: 21079
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to make a save game and load game?

Post by Tony Li »

Yes, it saves and loads variables. The complete list of what it saves is on the Saved Game Data page.
HaiiroMukuro
Posts: 80
Joined: Sun Jul 17, 2016 3:38 pm

Re: How to make a save game and load game?

Post by HaiiroMukuro »

Thank you! :D
HaiiroMukuro
Posts: 80
Joined: Sun Jul 17, 2016 3:38 pm

Re: How to make a save game and load game?

Post by HaiiroMukuro »

Gamesaver and Levelmanager can save/load the gameobjects that is set on active or not?
For example, I have a school gate and there are 2 gameobjects on the schoolgate. Those gameobjects are "GateClosed" and "GateOpen". If the player enters the gate, the gameobject "GateClosed" will be set on true and the gameobject "GateOpen" will be set on false.
if not, this should be done by scripting? Any help will be appreciated, thank you! :D
User avatar
Tony Li
Posts: 21079
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to make a save game and load game?

Post by Tony Li »

Hi,

You don't need to do any scripting. The Feature Demo scene contains an example. In the middle of the room, there is a terminal. This is actually two GameObjects: "TerminalActive" and "TerminalInactive". The save system controls them using a Persistent Active Data component and a Dialogue System variable.

I recommend this:

1. Add a Dialogue System variable named "SchoolGateIsOpen". Set the Type to Boolean, and set the Value to True.

2. Add a Persistent Active Data component to the schoolgate. Set the Target to GateOpen. Expand Condition > Lua Conditions, and add this Lua condition:

Code: Select all

Variable["SchoolGateIsOpen"] == true
3. Add another Persistent Active Data component to the schoolgate. Set the Target to GateClosed. Expand Condition > Lua Conditions, and add this Lua condition:

Code: Select all

Variable["SchoolGateIsOpen"] == false
When the player enters the gate, set the variable "SchoolGateIsOpen" false. For example, you can add a Lua Trigger set to OnTriggerEnter.
HaiiroMukuro
Posts: 80
Joined: Sun Jul 17, 2016 3:38 pm

Re: How to make a save game and load game?

Post by HaiiroMukuro »

Good day! :)
How can I delete a save game?
What will I do to make the game object such as Text records the time and date when the player saves the game?
Also, What will I do to make a panel appear that tells if the player wants to overwrite a game data?
Thank you for the help! :D
User avatar
Tony Li
Posts: 21079
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to make a save game and load game?

Post by Tony Li »

Hi,

For text records and a overwrite panel, I recommend using the free Menu Framework on the Dialogue System Extras page. It's the first download button under the EXTRAS section. It also lets players delete saved games.

To delete a saved game without the Menu Framework, you'll have to delete the PlayerPrefs keys. You can use a PlayerPrefs editor tool or write a script that uses PlayerPrefs.DeleteKey().
Post Reply