Keeps reference to a scene asset and tracks it's path in the editor, so it can be used in the game runtime.
It's a well known fact that scenes can't be referenced like prefabs, textures etc. The Unity SceneManager API works with relative scene paths or names.
Use this class to avoid manually typing and updating scene path strings - it will try to do it for you as best as it can, including when building the player.
- Download the single file directly: SceneReference
- OpenUPM support:
npm install -g openupm-cli
openupm add devlocker.utils.scenereference
- Github upm package - merge this to your
Packages/manifest.json
{
"dependencies": {
"devlocker.utils.scenereference": "https://github.com/NibbleByte/UnitySceneReference.git#upm"
}
- The SceneReference class works on lists, scriptable objects, game objects, multiple-select.
- Small button on the right to add or remove from the build settings. The +/- sign and color indicate what the operation would be.
- Paths are updated during build (guaranteed by the ISerializationCallbackReceiver).
Here is how it looks in debug mode (what data is stored):
Here is how it looks in the code:
Using the ISerializationCallbackReceiver was inspired by the JohannesMP's SceneReference implementation.
Another solution that builds a runtime look-up table instead of storing paths in the data members is Eflatun.SceneReference.