Saving and loading GameObjects and Prefabs

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

Your scene must have an Easy Save 3 Manager to save and load GameObjects. To add this to your scene, go to Assets > Easy Save 3 > Add Manager to Scene.

Once you have done this, GameObjects can be saved and loaded like any other object:

This will save and load the following:

  • layer, tag, name and hideFlags.
  • Components on the Natively-supported types list, or those which have been manually supported using an ES3Type OR …
  • … if the GameObject has an ES3GameObject Component, only the Components selected will be saved (see the Choosing which Components are saved section below).
  • All of the above for every child of the GameObject.

To save and load a prefab instance:

  1. Right-click the prefab and select Enable Easy Save for Prefab.
  2. Use ES3.Save to save the instance, or an array of instances if you have multiple instances.
  3. To load, use ES3.Load or ES3.LoadInto.
  4. Easy Save will create an instance of the prefab if it doesn’t exist in the scene.

You can choose which Components are saved by adding an ES3GameObject Component to the GameObject and checking which Components you wish to be saved.

Note that checking a Component doesn’t guarantee that it or it’s fields are serializable at runtime. It is recommended to only check Components which need to be saved, and which are known to be serializable. For example in most cases you shouldn’t check the ES3Prefab, ES3AutoSave or ES3GameObject Components, and doing so can cause errors.