Getting started

After importing Easy Save from the Asset Store, you can immediately use Easy Save from your scripts and from PlayMaker.

For information on saving and loading without code using Auto Save, see the Auto Save guide.

For information on PlayMaker actions available, see the PlayMaker Actions Overview.

Easy Save stores data as keys and values, much like a Dictionary.

For example, to save an integer to a key named myInt and load it back again, you could do:

If there’s no data to load, it will return the defaultValue.

If you don’t specify a defaultValue, you must ensure that there is data to load (for example using ES3.KeyExists):

To load a value into an existing reference, use ES3.LoadInto:

Note that ES3.LoadInto only works for reference types, not primitive types (e.g. int, string) or value types (e.g. structs).

You save and load classes, Components and ScriptableObjects in the same way as you would save any other data. However, there are some important things to note:

  • A class’s field will be saved if it:
    • Is public, or has a [SerializeField] attribute
    • Is not const or readonly
    • Does not have the [Obsolete] or [NonSerialized] attribute
    • Is a supported type
  • UnityEngine.Object types are stored by reference and value.
    • This means that if the instance you are loading already exists in a scene, it will load the data into that instance rather than creating a new one.
  • If a field of the class is a UnityEngine.Object type (e.g. Component, ScriptableObject, Texture2D, etc), it will be saved by reference.
    • This means that if the instance does not exist in the scene, a new instance will not be created upon loading and the field will be set to null.
    • If you wish to save them by value you should save them with a seperate ES3.Save call and load them before loading anything which references them.

GameObjects are saved and loaded like any other object. The following information about the GameObject will be saved:

This will save and load the following aspects of the GameObject:

For information on Saving and Loading Prefab Instances, see the Saving and Loading Prefab Instances guide.

You can also save and load Arrays, Lists, Dictionaries, Queues, Stacks and HashSets in the same way as you would save and load any other data.

Array

List

Dictionary

2D Array

Queue

HashSet

Stack

For most projects it makes sense to load in Start(), and save in OnApplicationQuit(), or OnApplicationPause(true) on mobile.

You can also use buttons to save and load.

The filePath parameter lets you specify where data is saved. The file or folder will be automatically created if it does not exist.

This can be a filename, a relative path, or an absolute path. For more information, see the Paths and Locations guide.

Filename

Relative path

Absolute path

Delete a key

Delete a file

Delete a directory

Change default settings by going to Window > Easy Save 3 > Settings.

Enable settings at runtime by providing an ES3Settings object as a parameter. See the ES3Settings page for more information.

Enable encryption

Enable compression

To see what types are supported, see our Supported Types guide.

As with all code, it is recommended that you handle errors. This can be performed using a try/catch block to catch exceptions, and display an appropriate message to the user when necessary. For example:

For more information on what types of error you may need to handle please see the Error Handling guide.