Skip to content

Simple way to reference a scene in Unity without typing manually the scene path.

License

Notifications You must be signed in to change notification settings

NibbleByte/UnitySceneReference

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity SceneReference

Keeps reference to a scene asset and tracks it's path in the editor, so it can be used in the game runtime.

Why

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.

Installation

npm install -g openupm-cli
openupm add devlocker.utils.scenereference

openupm

  • Github upm package - merge this to your Packages/manifest.json
{
  "dependencies": {
    "devlocker.utils.scenereference": "https://github.com/NibbleByte/UnitySceneReference.git#upm"
}

Features

  • 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 like:
SceneReference

Here is how it looks in debug mode (what data is stored):
SceneReferenceDebug

Here is how it looks in the code:
SceneReferenceCode

Credits & Similar Projects

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.

About

Simple way to reference a scene in Unity without typing manually the scene path.

Resources

License

Stars

Watchers

Forks

Packages

No packages published