Manual

SceneLoader

class in Doozy.Engine.SceneManagement / Inherits from MonoBehaviour

Description

The SceneLoader loads any Scene either by scene name or scene build index and updates a Progressor to show the loading progress. It can also trigger a set of 'actions' when the scene started loading (at 0% load progress) and/or when the scene has been loaded (but not activated) (at 90% load progress)

Static Properties

  • public static readonly List Database – Database used to keep track of all the SceneLoaders

Properties

  • public AsyncOperation CurrentAsyncOperation – Keeps track and manages the asyncOperation started when the scene loader begins to load a scene

  • public float InverseProgress – Returns the inverse value of current load Progress value (float between 1 and 0)

  • public float Progress – If an async operation is running, it returns the current load progress (float between 0 and 1)

Public Variables

  • public bool AllowSceneActivation – Allow Scenes to be activated as soon as it is ready. When loading a scene, Unity first loads the scene (load progress from 0% to 90%) and then activates it (load progress from 90% to 100%). It’s a two state process. This option can stop the scene activation (at 90% load progress), after the scene has been loaded and is ready. Useful if you need to load several scenes at once and activate them in a specific order and/or at a specific time.

  • public bool DebugMode – Enables relevant debug messages to be printed to the console

  • public SceneLoadBehavior LoadBehavior – Behavior when loading a scene

  • public GetSceneBy GetSceneBy – Determines what load method this SceneLoader will use by default if the load scene method is called without any parameters

  • public LoadSceneMode LoadSceneMode – Determines how the new scene is loaded by this SceneLoader if the load scene method is called without any parameters

  • public ProgressEvent OnProgressChanged – Event triggered when an async operation is running and its progress has been updated. Passes the Progress (float between 0 and 1)

  • public ProgressEvent OnInverseProgressChanged – Event triggered when an async operation is running and its progress has been updated. Passes the InverseProgress (float between 1 and 0). InverseProgress = 1 – Progress

  • public Progressor Progressor – Reference to a Progressor that allows animating anything (texts, images, animations…) in order to show the current scene load progress in a visual manner

  • public float SceneActivationDelay – Sets for how long will the SceneLoader wait, after a scene has been loaded, before it starts the scene activation process (works only if AllowSceneActivation is enabled). When loading a scene, Unity first loads the scene (load progress from 0% to 90%) and then activates it (load progress from 90% to 100%). It’s a two state process. This delay is after the scene has been loaded and before its activation (at 90% load progress)

  • public int SceneBuildIndex – Index of the Scene in the Build Settings to load (when GetSceneBy is set to GetSceneBy.ByName)

  • public string SceneName – Name or path of the Scene to load (when GetSceneBy is set to GetSceneBy.ByName)

  • public bool SelfDestructAfterSceneLoaded – Marks this SceneLoader to self destruct (to destroy itself) after it loads a Scene

Public Methods

  • public void ActivateLoadedScene() – Activate the current loaded scene. Works only if the SceneLoader has loaded a scene and its AllowSceneActivation option is set to false. This method enables the ‘allowSceneActivation’ for the CurrentAsyncOperation that has been paused at 90%. When loading a scene, Unity first loads the scene (load progress from 0% to 90%) and then activates it (load progress from 90% to 100%). It’s a two state process. This method is meant to be used for after the scene has been loaded and before its activation (at 90% load progress).

  • public void LoadSceneAsync() – Loads the Scene, with the current settings, asynchronously in the background

  • public Progressor LoadSceneAsync(int sceneBuildIndex, LoadSceneMode mode) – Loads a Scene asynchronously in the background, by its index in Build Settings

  • public Progressor LoadSceneAsync(string sceneName, LoadSceneMode mode) – Loads a Scene asynchronously in the background, by its name in Build Settings

  • public void LoadSceneAsyncAdditive(int sceneBuildIndex) – Loads a Scene asynchronously in the background, by its index in Build Settings, with the LoadSceneMode.Additive setting

  • public void LoadSceneAsyncAdditive(string sceneName) – Loads a Scene asynchronously in the background, by its name in Build Settings, with the LoadSceneMode.Additive setting

  • public void LoadSceneAsyncSingle(int sceneBuildIndex) – Loads a Scene asynchronously in the background, by its index in Build Settings, with the LoadSceneMode.Single setting

  • public void LoadSceneAsyncSingle(string sceneName) – Loads a Scene asynchronously in the background, by its name in Build Settings, with the LoadSceneMode.Single setting

  • public SceneLoader SetAllowSceneActivation(bool allowSceneActivation) – Set the AllowSceneActivation that that allows for Scenes to be activated as soon as it is ready

  • public SceneLoader SetLoadSceneBy(GetSceneBy loadSceneBy) – Set the GetSceneBy value, that determines what load method this SceneLoader will use by default

  • public SceneLoader SetLoadSceneMode(LoadSceneMode loadSceneMode) – Set the LoadSceneMode value, that determines how the new scene is loaded by this SceneLoader

  • public SceneLoader SetProgressor(Progressor progressor) – Set the Progressor reference that will get updates when this SceneLoader loads a scene

  • public SceneLoader SetSceneActivationDelay(float sceneActivationDelay) – Set the activation delay that determines how long will the SceneLoader wait, after a scene has been loaded, before it starts the scene activation process (works only if AllowSceneActivation is enabled)

  • public SceneLoader SetSceneBuildIndex(int sceneBuildIndex) – Set the SceneBuildIndex, in the Build Settings, of the Scene to load

  • public SceneLoader SetSceneName(string sceneName) – Set the SceneName, name or path, of the Scene to load

  • public SceneLoader SetSelfDestructAfterSceneLoaded(bool selfDestruct) – Set this SceneLoader to self destruct (to destroy itself) after it loads a Scene

Static Methods

  • public static void ActivateLoadedScenes() – Activates all the loaded scenes for all the SceneLoaders that have scenes ready to be activated. A scene is ready to be activated if the load progress is at 0.9 (90%).

  • public static SceneLoader GetLoader(Transform parent = null) – Creates a new GameObject with a SceneLoader script attached and then returns the reference to the newly created script