Saving and loading GameObjects and Prefabs
Code-free using Auto Save
For information on saving and loading GameObjects without code, please see the Auto Save guide.
Saving and loading GameObjects
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:
1 2 3 4 5 6 |
// Save a GameObject. ES3.Save("myGameObject", go); // Load a GameObject, automatically assigning it to an existing // GameObject if one exists, or create a new GameObject if not. ES3.Load("myGameObject", defaultGo); |
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.
- All of the above for every child of the GameObject.
Saving and loading prefab instances
To save and load a prefab instance:
- Right-click the prefab and select Enable Easy Save for Prefab.
- Use ES3.Save to save the instance, or an array of instances if you have multiple instances.
- To load, use ES3.Load or ES3.LoadInto.
- Easy Save will create an instance of the prefab if it doesn’t exist in the scene.