| Parameter | Description |
|---|---|
| loadableSceneId | The identifier for the specific scene asset to retrieve. |
Scene A valid Scene when a matching scene instance is currently loaded; otherwise an invalid Scene.
The Scene handle for a scene that is already loaded and originated from the given LoadableSceneId.
This is only meaningful after SceneManager.LoadSceneAsync (or an equivalent load path) has completed while the owning content directory was registered with ContentLoadManager.RegisterContentDirectory.
using System.Threading.Tasks; using Unity.Loading; using UnityEngine; using UnityEngine.SceneManagement;
public class GetSceneByLoadableSceneIdExample { // Example showing how to get the Scene handle after loading and activate it async Task Example(LoadableSceneId lobbySceneId) { AsyncOperation op = SceneManager.LoadSceneAsync(lobbySceneId, new LoadSceneParameters(LoadSceneMode.Additive)); while (!op.isDone) await Awaitable.NextFrameAsync();
Scene runtimeScene = SceneManager.GetSceneByLoadableSceneId(lobbySceneId); if (runtimeScene.IsValid()) SceneManager.SetActiveScene(runtimeScene); } }