Saving Data In Unity

There are two main ways to save data in Unity. The first is using something called PlayerPrefs. This basic method allows the saving and loading of basic data types quickly and easily.

set to save, get to read, easy as can be

For anything more complicated, you’re going to have to assign the System.Serializable attribute to your data, and then decide what data format you want to use, and include the proper namespace in your project. Whether you want to write out binary files using something like System.Runtime.Serialization.Formatters, or JSON using UnityEngine.JSONSerializeModule. Depending on the format that you use the process of writing your file to disk might be a bit different, but Unity does throw in a helpful way of defining where in the file system your data goes.

On Windows this writes to %userprofile%\AppData\Local\Packages\<productname>\LocalState but it will find a spot for your files no matter the device your game is running on