Info
- Abstraction above scenes and their loading
- Unity supports multiple ways to load and store scenes
- Async vs NonAsync loading
- Direct scene path or name vs Addressable scenes
- In general NonAsync loading has no benefits besides convenience, so we prioritize Async
- On the other hand, Direct and Addressable scenes may have their usage
Scene Definitions
- Scene definition represents a scene as a data container (
ScriptableObject)
- You can reference the base class
ASceneDefinition in your classes
- We can save it, send it over the network, etc.
- Inheritors:
DirectSceneDefinition - Saved as a path in the project
AddressableSceneDefinition - Saved as AssetReference
- Pure data container, contains no logic for loading.
- To handle logic, use SceneInstances, create one from definition by calling
CreateInstance()
Scene Instances
- Single instance of a scene definition
- You can reference the base class
ASceneInstance in your classes
- It contains a reference to the definition, its load state, and methods for handling
- Inheritors:
DirectSceneInstance - Instance for DirectSceneDefinition
AddressableSceneInstance - Instance for AddressableSceneDefinition
- Methods:
Load(bool setActive = true) - Load the scene and set it active (or not, optionally), async
Unload() - Unload the scene out of the way, async
SetActive() - Set the scene as the current active scene