Saving and loading references
When you save a class or script, by default Easy Save will store it’s fields by reference if they inherit from UnityEngine.Object.
To do this, Easy Save has a reference manager which stores IDs for the references in your scene.
Reference managers are scene-specific, so you should have one in every scene in which you’re saving and loading references. You shouldn’t put it in a prefab or mark it as DontDestroyOnLoad.
What is automatically added to the reference manager
When you save a scene or enter play mode, Easy Save will automatically add the following references to the reference manager:
- All GameObjects and Components in your scene
- All direct UnityEngine.Object references stored in your Component.
- All prefabs which are referenced by your scene and have an ES3Prefab Component attached
By default only direct references of Components will be added. For example, a ScriptableObject held in a Component’s field will be added, but anything referenced by that ScriptableObject will not be added.
To increase the depth you can go to Tools > Easy Save 3 > Settings > Editor Settings, and increase the ‘Reference depth’. Similarly, if you feel that gathering references is slowing down your project, you can decrease the depth.
Manually adding a reference to the manager
To manually add an asset to the reference manager, right-click it and press Add Reference to Manager.
Optimising references
Sometimes the reference manager will keep references to things which are no longer used by your scene.
To remove any references from the manager which are not directly referenced by your scene, press the Optimize button on the ES3 Reference Mgr component of the Easy Save 3 Manager in your scene.
What happens if I delete a reference manager?
Deleting a reference manager will usually invalidate any existing save data you have, because the reference IDs will no longer exist. Re-adding the reference manager will generate new IDs, so the save data will still be invalid.
In this case you can either roll back your project to a time before you deleted the reference manager, or you would need to manually change the reference IDs in the ES3ReferenceMgr’s ‘References’ foldout to match those in the save file.