Autogenerated ScriptableObjects that are stable references to the scenes configured in Unity Build Settings.
- Scene references are automatically generated/refreshed whenever the scenes in Build Settings change or any scene is renamed/moved, no code or manual setup required
- Scene references are stable and based on their GUID: if a scene is renamed/moved, all existing references to the corresponding
SceneReferenceare maintained - No extra files are created in your project: everything lives in the asset imported from an empty file that lives in the package's own folder
- Utility methods
SceneReference.Load,SceneReference.LoadAsyncandSceneReference.UnloadAsyncto load/unload scenes directly from references
- Only Scenes enabled in Build Settings are generated
- Referencing scenes that are not in Build Settings is not supported at all
- If you have multiple build configurations that involve changing which Scenes are enabled, previous references to disabled ones will be missing from the build and will be
nullat runtime
Either:
- Use the openupm registry and install this package using the openupm-cli:
openupm add com.gilzoide.stable-scene-reference - Install via Unity Package Manager using the following URL:
https://github.com/gilzoide/unity-scene-reference.git#1.0.0 - Clone this repository or download a snapshot of it directly inside your project's
AssetsorPackagesfolder.
- Declare SceneReference fields in your scripts
- Use the Inspector to assign any of the
SceneReferences automatically generated from your project's Build Settings - Use
SceneReference.Load,SceneReference.LoadAsyncandSceneReference.UnloadAsyncto load/unload scenes. Alternatively, useSceneReference.BuildIndexorSceneReference.Pathas argument to SceneManager load/unload methods. - Enjoy 🍾