SceneLoader
unknown
java
2 years ago
873 B
20
Indexable
public class SceneLoader : ISceneLoader
{
public async UniTask Load(string nextScene)
{
Application.backgroundLoadingPriority = ThreadPriority.High;
AsyncOperationHandle<SceneInstance> handler =
Addressables.LoadSceneAsync(nextScene, LoadSceneMode.Single, false);
handler.Completed += handle =>
{
if (handle.Status == AsyncOperationStatus.Succeeded)
{
Debug.Log($"Scene {nextScene} loaded successfully.");
handler.Result.ActivateAsync().ToUniTask();
}
else
{
Debug.LogError($"Failed to load scene {nextScene}.");
}
};
await handler.ToUniTask();
}
}Editor is loading...
Leave a Comment