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 maintain 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 ...
Get Mastering Unity 2D Game Development - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.