Game Development Reference
In-Depth Information
Before restoring your game in Unity, jump over to the Application.persistentDataPath folder on
your system, and you should find the save-game XML file, which is the result of the save operation.
Open the file in MonoDevelop, ensuring that Code Folding is enabled in the Options dialog, and
inspect the contents of the file to make sure that the data saved as expected (see Figure 9-6 ).
Checking the file in this way is good debugging practice—it's a great way to inspect the data being
saved and to check for errors and issues. It's also what you'll need to do if you ever want to tweak or
change the data inside the file.
Figure 9-6. Verifying the save-game data
Note If you find that your data is not being loaded or saved as expected after testing, be sure to register
your enemy objects with the notifications manager to receive load-and-save event notifications (see the
companion source code for more details); for example:
//Add listener for saving games
GameManager.Notifications.AddListener(this, "SaveGamePrepare");
GameManager.Notifications.AddListener(this, "LoadGameComplete");
Now return to CMOD in Unity and restore the game using the main menu. See Figure 9-7 . Voilà!
Excellent work! We've created load and save functionality.
Search WWH ::




Custom Search