09 Sept 2014Unity15 Comments

Unity3d – Saving Data

Here I’m going to explain some basic and widely used methods to save game data in your unity game.

1) Using PlayerPrefs

What are PlayerPrefs ?

Saving data using PlayerPrefs is easy. You don’t need to bother about anything, unity will do it for you :) but there are some limitations :D in PlayerPrefs you can save premitive types only, in unity – webplayer file size is limited to 1MB

Whenever save a value into playerprefbs need to set a key, by using that key able to retrieve that value any time

In reality its easier to save entire class and retrieve it back. but the limitations of PlayerPrefs is, it only works with primitive data types. in order to store objects using playerprefs we need to serialize them. Using BinaryFormatter and its Serialized methods we can serialized objects. then we can save it like we did before :)

What is serialization ?

2). Saving Data into file

We can save entire class into file by serializing it like we did in previous step

Download complete Unity Project