Static Unity-style API for scene loading, unloading, and event subscriptions.
More...
#include <SceneManagement.hpp>
Static Unity-style API for scene loading, unloading, and event subscriptions.
Usage:
if (op->isDone) { ... }
op->onComplete = [](
const SceneInfo& info) { ... };
@ Additive
Load the new scene alongside existing ones.
Definition SceneManagement.hpp:17
static std::shared_ptr< AsyncOperation > loadSceneAsync(const std::string &nameOrPath, LoadSceneMode mode=LoadSceneMode::Single, bool discardPendingAsync=true)
Load a scene asynchronously by name or path.
Definition SceneManagement.cpp:69
static SceneInfo getSceneInfo(int sceneId)
Get scene info by integer ID.
Definition SceneManagement.cpp:136
static void unloadScene(const std::string &nameOrPath)
Unload a scene by its name or path.
Definition SceneManagement.cpp:103
static void onSceneUnloaded(std::function< void(const SceneInfo &)> callback)
Subscribe a callback to be fired whenever any scene is unloaded.
Definition SceneManagement.cpp:122
static void loadScene(const std::string &nameOrPath, LoadSceneMode mode=LoadSceneMode::Single, bool discardPendingAsync=true)
Load a scene by name or path.
Definition SceneManagement.cpp:41
static std::vector< SceneInfo > getLoadedScenes()
Returns all currently loaded scenes.
Definition SceneManagement.cpp:131
static void onSceneLoaded(std::function< void(const SceneInfo &)> callback)
Subscribe a callback to be fired whenever any scene finishes loading.
Definition SceneManagement.cpp:117
Lightweight descriptor for a known or loaded scene.
Definition SceneManagement.hpp:24
◆ getLoadedScenes()
| std::vector< SceneInfo > SceneManagement::getLoadedScenes |
( |
| ) |
|
|
static |
Returns all currently loaded scenes.
◆ getSceneInfo() [1/2]
| SceneInfo SceneManagement::getSceneInfo |
( |
const std::string & | nameOrPath | ) |
|
|
static |
Get scene info by name or path.
◆ getSceneInfo() [2/2]
| SceneInfo SceneManagement::getSceneInfo |
( |
int | sceneId | ) |
|
|
static |
Get scene info by integer ID.
◆ loadScene() [1/2]
Load a scene by name or path.
- Parameters
-
| nameOrPath | Scene name (e.g. "level1") or path (e.g. "assets/scenes/level1.json"). |
| mode | Single replaces all scenes; Additive adds alongside existing ones. |
| discardPendingAsync | If true, cancels any in-flight async loads before proceeding. |
◆ loadScene() [2/2]
Load a scene by its integer ID (from a previously loaded scene).
- Parameters
-
| sceneId | The numeric ID of the scene to load/reload. |
| mode | Single replaces all scenes; Additive adds alongside existing ones. |
| discardPendingAsync | If true, cancels any in-flight async loads before proceeding. |
◆ loadSceneAsync() [1/2]
Load a scene asynchronously by name or path.
- Parameters
-
| nameOrPath | Scene name or path. |
| mode | Single or Additive. |
| discardPendingAsync | If true, cancels any in-flight async loads before proceeding. |
- Returns
- Shared handle to track load progress.
◆ loadSceneAsync() [2/2]
Load a scene asynchronously by its integer ID.
- Parameters
-
| sceneId | The numeric ID of the scene to reload. |
| mode | Single or Additive. |
| discardPendingAsync | If true, cancels any in-flight async loads before proceeding. |
- Returns
- Shared handle to track load progress.
◆ onSceneLoaded()
| void SceneManagement::onSceneLoaded |
( |
std::function< void(const SceneInfo &)> | callback | ) |
|
|
static |
Subscribe a callback to be fired whenever any scene finishes loading.
- Parameters
-
| callback | Receives the SceneInfo of the loaded scene. |
◆ onSceneUnloaded()
| void SceneManagement::onSceneUnloaded |
( |
std::function< void(const SceneInfo &)> | callback | ) |
|
|
static |
Subscribe a callback to be fired whenever any scene is unloaded.
- Parameters
-
| callback | Receives the SceneInfo of the unloaded scene. |
◆ setSceneManager()
| void SceneManagement::setSceneManager |
( |
SceneManager * | manager | ) |
|
|
static |
◆ unloadScene() [1/2]
| void SceneManagement::unloadScene |
( |
const std::string & | nameOrPath | ) |
|
|
static |
Unload a scene by its name or path.
- Parameters
-
| nameOrPath | Scene name (e.g. "level1") or full path. |
◆ unloadScene() [2/2]
| void SceneManagement::unloadScene |
( |
int | sceneId | ) |
|
|
static |
Unload a scene by its integer ID.
- Parameters
-
◆ s_sceneManager
The documentation for this class was generated from the following files: