Keeping track of the player's progress and user settings during a game is vital to give your game a greater feel of depth and content. In this recipe, we will learn how to make our game remember the player's score between the different levels (scenes).
We have included a complete project in a Unity package named game_HigherOrLower
in the 1362_10_04
folder. In order to follow this recipe, we will import this package as the starting point.
To save and load player data, follow these steps:
Create a new 2D project and import the
game_HigherOrLower
package.Add each of the scenes to the build in the sequence (
scene0_mainMenu
, thenscene1_gamePlaying
, and so on).Make yourself familiar with the game by playing it a few times and examining the contents of the scenes. The game starts on the
scene0_mainMenu
scene, inside theScenes
folder.Let's create a class to store the number of correct and incorrect guesses made by...