O'Reilly logo

Unity 5.x Cookbook by Chico Queiroz, Matt Smith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Saving and loading player data – using static properties

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).

Getting ready

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.

How to do it...

To save and load player data, follow these steps:

  1. Create a new 2D project and import the game_HigherOrLower package.
  2. Add each of the scenes to the build in the sequence (scene0_mainMenu, then scene1_gamePlaying, and so on).
  3. Make yourself ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required