Unity Cookbook. Saving and loading

Saving and loading

Data persistence between sessions

PlayerPrefs

  • Script Reference: PlayerPrefs
  • You can store ints, floats or strings in PlayerPrefs
    • …which are stored in the Registry :D
    • Not preferred for save files!!!
    • More suitable for saving game preferences
  • Set value with PlayerPrefs.SetInt(intValue)
  • Clear saved data with Edit > Clear All PlayerPrefs

Serializing data to/from JSON