O'Reilly logo

Mastering Unity 2D Game Development by Simon Jackson

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

Working with settings

Saving data is always important, especially in games where you need to keep track of the player's progress or at the very least a track record of scores, plays, and other important data.

Within Unity, there is only one method of storing data natively, and that is PlayerPrefs. It is very simple to use and very flexible, although it does have a hard limit of 1 MB of storage for the web player. It is possible to serialize data into PlayerPrefs (and some developers do this), but generally if you need to serialize, most developers build their own system.

Using PlayerPrefs

PlayerPrefs is simply a key dictionary to store individual variables as a key in the Unity runtime data store. On its own, it has to read each and every scene at ...

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