Skip to main content

Scenes System

The Scenes System is one of the core Systems that Construct natively offers. It's a wrapper of Unity's SceneManager and adds functionalities on top of it. For instance, it allows to use SceneReference as parameters, allows to load Scenes directly from Addressables and to specify the transition to play when changing or loading a new Scene (ILoadingVew.)

System Setup

Scenes System Inspector

The only parameter in the inspector is an optional SceneReference to a default loading scene. If present, whenever a new Scene is loaded the loading Scene will be loaded first. At this point, the Scenes System tries to get a ILoadingVew Object from it and tries to show it as a transition effect (see Loading View for more information.) This process can be used to mask an abrupt scene change with some visual effects.

How to Use

A running Scenes System offers the following methods to load, add and remove scenes:

SceneOperation LoadScene(string scene, bool autoHideLoadingView = true)
SceneOperation LoadScene(SceneReference scene, bool autoHideLoadingView = true)

SceneOperation AddScene(string scene)
SceneOperation AddScene(SceneReference scene)

void RemoveScene(string scene, Action callback)

Loading a Scene is semantically equivalent to loading a scene using the SceneManager in single mode, while Adding a Scene is equivalent to the additive mode (see the official documentation.)

Apart from RemoveScene, all above methods return a SceneOperation than can be used in Coroutines.

private IEnumerator WaitForScene(SceneReference reference)
{
SceneOperation sceneOperation = ScenesSystem.Instance.LoadScene(reference, false);
yield return sceneOperation;
sceneOperation.HideCurrentLoadingView(); // OR ScenesSystem.Instance.HideCurrentLoadingView();
}
note

LoadScene overloads have an optional autoHideLoadingView argument that if false prevent the System from hiding the Loading View after loading the new scene. This is so it can be hidden manually in the new scene after some initialization by calling SceneSystem.Instance.HideCurrentLoadingView().

If no Loading Scene was supplied or no Loading View was found, both the argument and a call to the hiding method won't have any effect.

tip

There are LoadScene overloads that also accept a specific loading Scene as parameter. This loading Scene will always have priority over the default one specified in the Inspector, if any. See the Scenes System reference for more information.