using UnityEngine;
using UnityEngine.SceneManagement;
public class AsyncLoadSceneDemo : MonoBehaviour
{
void Start()
{
LoadNextSceneAsync();
}
void LoadNextSceneAsync()
{
//Create a object of AsyncOperation to track the scene loading process.
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync("StartScene", LoadSceneMode.Single);
//By default, the value of asyncLoad.allowSceneActivation is true, which means that StartScene will automatically be activated after loading is completed.
asyncLoad.allowSceneActivation = true;
//It's possible to add a callback method which will be triggered once the loading of StartScene is finished.
asyncLoad.completed += OnSceneLoaded;
}
void OnSceneLoaded(AsyncOperation obj)
{
Debug.Log("The Scene" + obj.progress + " has been loaded and ready.");
//Excute the following code here once the loading of StartScene is finished.
}
}
04-15
06-28
603
01-16
3506
08-22
5160
05-08
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交