O'Reilly logo

Mastering Unity 5.x by Alan Thorn

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 data for Dead Keys

For Dead Keys, our level loading needs are simple, technically. We simply need to save the latest level we have reached, and then restore back to the beginning of that level every time the game is started. To do this, we can use the Player preferences class. Create a new script, named LevelSaveRestore.cs.

Saving data for Dead Keys

Creating a new save state script

This script file should be attached to one, and only one, empty object in the scene, which is active at level start up, and this should happen for every playable level in the game. The full code for the script file is shown as follows:

using System.Collections; using System.Collections.Generic; ...

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