기술 자료

Unity Engine

Unity Engine

GetSceneByLoadableSceneId(LoadableSceneId)

The Scene handle for a scene that is already loaded and originated from the given LoadableSceneId.
읽는 시간 1분최근 업데이트: 한 달 전

Definition

public static Scene GetSceneByLoadableSceneId(LoadableSceneId loadableSceneId)

Parameters

loadableSceneId

The identifier for the specific scene asset to retrieve.

Returns

Type

Description

SceneA valid Scene when a matching scene instance is currently loaded; otherwise an invalid Scene.

Remarks

This is only meaningful after SceneManager.LoadSceneAsync (or an equivalent load path) has completed while the owning content directory was registered with ContentLoadManager.RegisterContentDirectory.

Examples

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); }}