Scene Status Saver lets you keep the status (snapshot) of your scenes along time. It can be useful in some situations like in the following examples:
- Your game zones are split into independent scenes. You want to keep the position (or even other properties) of some items when coming back from a different zone.
- You want to create save state snapshots during the game. You also want to let the user save the progress at any time and to go back to the previous one at will. Please have a look at the samples included with the asset to have some practical examples.
Quick start
To keep status between different scenes, follow the steps below:
- Drag and drop the Scene Status Saver prefab into your scene.
- Customize the available settings. Check Configuration section for more details.
- Add the SceneStatusSaverElement to each Game Object in the scene you want to keep its status.
- For each of those Game Object set the Components of which you want to keep the status (you can select the Game Object’s components or child components, but do not set components from other Game Objects in the scene, only the components at the same level SceneStatusSaverElement is or below).
- Include the following line in your scripts BEFORE switching to another scene.
SceneStatusSaver.SaveCurrentSnapshot();
- Done!
Best practices
Questions & Answers
What if a Game Object is not in the scene anymore?
The Game Object will be ignored. References to that Game Object will become null.
How do the Scene Status Saver parameters behave if every scene has an instance of Scene Status Saver?
The used parameters will be the ones found for the first loaded scene which contains the Scene Status Saver prefab. As soon as the Scene Status Saver prefab is found it will stay alive (Don’tDestroyOnLoad) until the end of the game (unless you remove it). Newfound Scene Status Saver prefabs for future scenes will be removed at runtime, so only one instance of the prefab will exist at once.
Are multiple instances of the same component allowed for the same Game Object?
No. Every component you want to save should be unique within the Game Object.
What about additive scene loading?
Scene Status Saver works with individual scenes. It relies on the active scene when saving the data, so the behavior for multiple scenes at once may not work as expected. In case you want to use them, make sure you save and load the data with the same active scene.
What if a component is not compatible with Scene Status Saver and I want to keep its status?
Non-supported components can be addressed by creating a custom proxy MonoBehaviour which could deal with the values you want to keep saved. Have a look at IComponentProxy.