Hey guys!
Just wanted to note that I love the "Dialogue System for Unity" and it's really been working for me! I just wanted to get some help with the Save System.
I've been following the tutorials and I noticed that the "Save System" tutorial uses the "PlayMaker" system. I wouldn't mind going and purchasing this package as well, but I'd like to see if I could get the Save System to work without additional purchases. The tutorial said that all I'd need to do to access the Level Manager's functions would be to call it from a script ("LevelManager.LoadLevel(levelName);" for example). However, when I do this, I get an error saying that I can't call the it because it is static. BUT I cannot get the Level Manager in the project via GetComponent<LevelManager> because its not part of the original "Monolithic" system.
I know the answer is probably really simple and you will all think I'm a moron for not figuring it out on my own - but if you could help me out, I'll take all the criticism you want to dish out.
P.S. the tutorial is here: https://www.youtube.com/watch?v=19yiQ_g ... e=youtu.be
(The exact spot in the video is at 6:35).
Using the Save System only using Scripts (No PlayMaker)
Re: Using the Save System only using Scripts (No PlayMaker)
Hi,
You don't need any additional purchases.
1. Add a Level Manager component to your Dialogue Manager GameObject.
2. To change levels, run this code:
You can also use this code to load a saved game:
It assumes that your saved game data is in a string named "mySaveData".
To get the saved game data from the current scene (i.e., to save the game), call:
Then it's up to you to store the data somewhere.
You could use the GameSaver component to save and load from PlayerPrefs. It's a wrapper for PersistentDataManager and LevelManager.
Or you could use your own code to save the string somewhere, for example to a local disk file.
You may also be interested in the Dialogue System Menu Template Prefab on the Extras page. This is a complete framework that provides a menu to load and save games in slots, pause the game, set options, etc.
API References:
- LevelManager
- PersistentDataManager
You don't need any additional purchases.
1. Add a Level Manager component to your Dialogue Manager GameObject.
2. To change levels, run this code:
Code: Select all
using PixelCrushers.DialogueSystem; //<-- Add to "using" section at top of script.
// In your "change levels" method:
var levelManager = DialogueManager.Instance.GetComponent<LevelManager>();
if (levelManager == null) {
Debug.LogError("Can't find LevelManager on Dialogue Manager");
} else {
levelManager.LoadLevel("myNewLevel");
}
Code: Select all
levelManager.LoadGame(mySaveData);
To get the saved game data from the current scene (i.e., to save the game), call:
Code: Select all
string mySaveData = PersistentDataManager.GetSaveData();
You could use the GameSaver component to save and load from PlayerPrefs. It's a wrapper for PersistentDataManager and LevelManager.
Or you could use your own code to save the string somewhere, for example to a local disk file.
You may also be interested in the Dialogue System Menu Template Prefab on the Extras page. This is a complete framework that provides a menu to load and save games in slots, pause the game, set options, etc.
API References:
- LevelManager
- PersistentDataManager
Re: Using the Save System only using Scripts (No PlayMaker)
Tony,
Thank you SO much! This is EXACTLY what I was looking for (plus extra coolness!). My Saving and Loading is now working correctly. Again, thank you so much for the quick reply and the level of detail that you provided. HUGE help!
P.S. Best Forum Help EVER!
Thank you SO much! This is EXACTLY what I was looking for (plus extra coolness!). My Saving and Loading is now working correctly. Again, thank you so much for the quick reply and the level of detail that you provided. HUGE help!
P.S. Best Forum Help EVER!
Re: Using the Save System only using Scripts (No PlayMaker)
Happy to help!