Auto Save: Code-free Saving and Loading

ES2 Auto Save WindowImportant: Auto Save is currently in beta, and as such certain features (such as saving collections, references and null references) are disabled. If using this beta in a product, please ensure that you test it thoroughly before release! While in beta, it is provided without warranty.

Auto Save is a visual scripting tool for the Unity 5 Editor which allows you to save and load data without any programming.

It can save Components, Variables and even references to Prefabs.

To enable Auto Save for your scene:

  1. Go to Window > Easy Save 2 > Auto Save > Scene
  2. Press the ‘Click to enable Auto Save for this scene’ button.

This will reveal the visual scripting tool, which displays your scene hierarchy in a list. Click the name of an object or variable and it will show it’s instance variables.

Beside each of these is a ES2 Logo Icon Grey 20x20 icon, which allows you to tell Auto Save to save and load it. Click the icon and it will become highlighted (Easy Save 2 Logo Icon), showing that it will be auto saved.

It’s also possible to auto save prefabs, which will automatically be instantiated when loading.

To auto save prefabs, right-click them in the Project hierarchy and select Easy Save 2 > Enable Auto Save for Prefab(s).

You can then access these prefabs,and their children, using the Auto Save window, underneath the Prefabs tab.

The Settings tab in the Auto Save window lets you choose a variety of options. Here’s a summary of the main options:

ES2 Auto Save SettingsWhen to Load / When to Save

This allows you to choose when to save and load, and corresponds to Unity’s Event Functions.

It’s recommended to load on Start on all platforms, to save on On Application Pause on mobile platforms, and On Application Quit on all non-mobile platforms.

Filename/Path

This is a relative or absolute path to a file which will be created to store our Auto Save data. See the Paths guide for more information.

Tag

A tag allows us to uniquely identify this Auto Save data in a file which might contain many different groups of Auto Save data.

For example, if you plan to enable Auto Save in two different scenes which save to the same file, you should use a different tag for each scene. Alternatively, you can set a different filename for each scene.

Sometimes you might want to trigger Auto Save using a button, or in your own event. No problem!

Simply find the ES2 Auto Save Manager script attached to the ES2 Auto Save Manager object, and call it’s Save() and Load() methods.

The easiest way to get the ES2 Auto Save Manager in code is as follows:

When doing this, you may also want to set the Save and Load events in the settings to None so that the game is only auto saved when you manually trigger it.

Playmaker users can also trigger an Auto Save to save and load using the Save Auto Save and Load Auto Save Actions.

  • Sometimes the selection in Auto Save / Prefabs is not saved when quitting Unity in Unity 5.3.3f1.
    • Bug at Unity’s end. Use 5.3.2f1 or below instead, or wait for Unity’s fix.