Additive Scene Manager
An API For Level Streaming in Unity.
Loading...
Searching...
No Matches

The main class used for loading, unloading, and reloading Scenes. More...

Public Member Functions

void LoadScene (string sceneName, bool allowSceneActivation=true, bool setActiveScene=false)
 Load a single scene by name additively and asynchronously.
void LoadScenes (string[] sceneNames, bool allowSceneActivation=true, int indexSetActiveScene=-1)
 Load an array of scenes by name additively and asynchronously.
void LoadScenes (List< AdditiveScene > additiveScenes, bool allowSceneActivation=true, int indexSetActiveScene=-1)
 Load a list of AdditiveScenes additively and asynchronously.
void UnloadScene (string sceneName)
 Unload a single scene by name.
void UnloadScenes (string[] sceneNames)
 Unload an array of scenes by name.
void UnloadAllScenes ()
 Unload all currently loaded scenes.
void UnloadAllScenesExcept (string exception)
 Unload all scenes except a single scene.
void UnloadAllScenesExcept (string[] exceptions)
 Unload all scenes except an array of scenes.
void UnloadAllScenesExcept (List< AdditiveScene > exceptions)
 Unload all scenes except a list of AdditiveScenes.
void ReloadScene (string sceneName)
 Reload a single scene.
void ReloadScenes (string[] sceneNames)
 Reloads an array of scenes.
void ActivateScene (string sceneName)
 Complete the loading process on a single scene by name.
void ActivateScene (AdditiveScene additiveScene)
 Complete the loading process on a single scene.
void ShowInGameUI (bool show)
 Use this function to spawn or destroy the In-Game UI.

Public Attributes

ThreadPriority threadPriority = ThreadPriority.Low
 The ThreadPriority which will be assigned to Application.backgroundLoadingPriority.
bool bShowInGameUI
 Show the In-Game Scene Controller UI.
Dictionary< string, AsyncOperation > asyncOperations = new()
 The AsyncOperation for loading a level is saved into a dictionary where string is the Scene Name.

Static Public Attributes

static SceneController Instance
 Static singleton of this class.

Private Member Functions

async void LoadSceneAsync (string sceneName, bool allowSceneActivation=true, bool setActiveScene=false)
 The internal Task responsibe for loading scenes.
async void UnloadSceneAsync (string sceneName)
 The internal Task responsibe for unloading scenes.
async void ReloadSceneAsync (string sceneName)
 The internal Task responsibe for reloading scenes.
IEnumerator IActivateScene (AdditiveScene additiveScene)
 The internal Coroutine responsibe for activating scenes.
VisualElement CreateLoadedSceneListBox ()
 Creates the In-Game UI Elements.
void OnSceneButtonClick (ClickEvent evt)
 Event is called when clicking on the small button next to a Scene on the In-Game UI.

Private Attributes

ListView listViewLoadedScenes
 A ListView to display all of the Loaded Scenes on the In-Game UI.

Detailed Description

The main class used for loading, unloading, and reloading Scenes.

A singleton of this class exists at SceneController.Instance.

Member Function Documentation

◆ ActivateScene() [1/2]

void ActivateScene ( AdditiveScene additiveScene)

Complete the loading process on a single scene.

Sets the 'allowSceneActivation' bool to true, advancing a scene's loading progress from 0.9 to 1. This does not make it the "Active Scene". It only "activates" the scene, making it visible and triggering the Awake, OnEnable, and Start functions.

Parameters
additiveSceneThe AdditiveScene to activate.

◆ ActivateScene() [2/2]

void ActivateScene ( string sceneName)

Complete the loading process on a single scene by name.

Sets the 'allowSceneActivation' bool to true, advancing a scene's loading progress from 0.9 to 1. This does not make it the "Active Scene". It only "activates" the scene, making it visible and triggering the Awake, OnEnable, and Start functions.

Parameters
sceneNameThe unique name of the scene to activate.

◆ CreateLoadedSceneListBox()

VisualElement CreateLoadedSceneListBox ( )
private

Creates the In-Game UI Elements.

Returns
The VisualElement that holds the entire In-Game UI.

◆ IActivateScene()

IEnumerator IActivateScene ( AdditiveScene additiveScene)
private

The internal Coroutine responsibe for activating scenes.

Parameters
additiveSceneThe AdditiveScene to activate.

◆ LoadScene()

void LoadScene ( string sceneName,
bool allowSceneActivation = true,
bool setActiveScene = false )

Load a single scene by name additively and asynchronously.

Parameters
sceneNameThe unique name of the scene to load.
allowSceneActivationIf true, the scene will automatically activate when it has finished loading.
setActiveSceneIf true, the scene will become the Active Scene when it has finished loading.

◆ LoadSceneAsync()

async void LoadSceneAsync ( string sceneName,
bool allowSceneActivation = true,
bool setActiveScene = false )
private

The internal Task responsibe for loading scenes.

Parameters
sceneNameThe unique name of the scene to load.
allowSceneActivationIf true, the scene will automatically activate when it has finished loading.
setActiveSceneIf true, the scene will become the Active Scene when it has finished loading.

◆ LoadScenes() [1/2]

void LoadScenes ( List< AdditiveScene > additiveScenes,
bool allowSceneActivation = true,
int indexSetActiveScene = -1 )

Load a list of AdditiveScenes additively and asynchronously.

Parameters
additiveScenesThe list of AdditiveScenes to load.
allowSceneActivationIf true, all scenes will automatically activate when they have finished loading.
indexSetActiveSceneArray index of the scene will become the Active Scene when it has finished loading: -1 = Don't change Active Scene.

◆ LoadScenes() [2/2]

void LoadScenes ( string[] sceneNames,
bool allowSceneActivation = true,
int indexSetActiveScene = -1 )

Load an array of scenes by name additively and asynchronously.

Parameters
sceneNamesThe array of unique scene names to load.
allowSceneActivationIf true, all scenes will automatically activate when they have finished loading.
indexSetActiveSceneArray index of the scene will become the Active Scene when it has finished loading: -1 = Don't change Active Scene.

◆ OnSceneButtonClick()

void OnSceneButtonClick ( ClickEvent evt)
private

Event is called when clicking on the small button next to a Scene on the In-Game UI.

◆ ReloadScene()

void ReloadScene ( string sceneName)

Reload a single scene.

Persistent Scenes will not be reloaded.

Parameters
sceneNameThe unique name of the scene to reload.

◆ ReloadSceneAsync()

async void ReloadSceneAsync ( string sceneName)
private

The internal Task responsibe for reloading scenes.

Parameters
sceneNameThe unique name of a single scene to reload.

◆ ReloadScenes()

void ReloadScenes ( string[] sceneNames)

Reloads an array of scenes.

Persistent scenes will not be reloaded.

Parameters
sceneNames

◆ ShowInGameUI()

void ShowInGameUI ( bool show)

Use this function to spawn or destroy the In-Game UI.

Parameters
showTrue = UI is created. False = UI is destroyed.

◆ UnloadAllScenes()

void UnloadAllScenes ( )

Unload all currently loaded scenes.

Persistent Scenes will not be unloaded.

◆ UnloadAllScenesExcept() [1/3]

void UnloadAllScenesExcept ( List< AdditiveScene > exceptions)

Unload all scenes except a list of AdditiveScenes.

Persistent Scenes will not be unloaded.

Parameters
exceptionsA list of AdditiveScenes which will not be unloaded.

◆ UnloadAllScenesExcept() [2/3]

void UnloadAllScenesExcept ( string exception)

Unload all scenes except a single scene.

Persistent Scenes will not be unloaded.

Parameters
exceptionThe scene name which will not be unloaded.

◆ UnloadAllScenesExcept() [3/3]

void UnloadAllScenesExcept ( string[] exceptions)

Unload all scenes except an array of scenes.

Persistent Scenes will not be unloaded.

Parameters
exceptionsAn array of scene names which will not be unloaded.

◆ UnloadScene()

void UnloadScene ( string sceneName)

Unload a single scene by name.

Persistent Scenes will not be unloaded.

Parameters
sceneNameThe unique name of the scene to unload.

◆ UnloadSceneAsync()

async void UnloadSceneAsync ( string sceneName)
private

The internal Task responsibe for unloading scenes.

Parameters
sceneNameThe unique name of the scene to unload.

◆ UnloadScenes()

void UnloadScenes ( string[] sceneNames)

Unload an array of scenes by name.

Persistent Scenes will not be unloaded.

Parameters
sceneNamesThe array of unique scene names to unload.

Member Data Documentation

◆ asyncOperations

Dictionary<string, AsyncOperation> asyncOperations = new()

The AsyncOperation for loading a level is saved into a dictionary where string is the Scene Name.

◆ bShowInGameUI

bool bShowInGameUI

Show the In-Game Scene Controller UI.

◆ Instance

SceneController Instance
static

Static singleton of this class.

◆ listViewLoadedScenes

ListView listViewLoadedScenes
private

A ListView to display all of the Loaded Scenes on the In-Game UI.

◆ threadPriority

ThreadPriority threadPriority = ThreadPriority.Low

The ThreadPriority which will be assigned to Application.backgroundLoadingPriority.


The documentation for this class was generated from the following file:
  • U:/UnityProjects/AdditiveSceneManager/Assets/AdditiveSceneManager/Scripts/SceneController/SceneController.cs