SceneLoader
Anonymous
java
02/23/2024 7:53 PM
1.1 KB
37
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