1、创建一个空物体AsyncTest
2、创建一个C#脚本AsyncTest并添加的上面的空物体
3、打开脚本并应用场景管理方法
using UnityEngine.SceneManagement;
4、书写一个协程方法
public class AsyncTest : MonoBehaviour
{
AsyncOperation operation;
// Start is called before the first frame update
void Start()
{
StartCoroutine(loadScene());
}
//协程方法用来异步加载场景
IEnumerator loadScene()
{
operation = SceneManager.LoadSceneAsync(1); //加载1号场景
//加载完场景后不要自动跳转
operation.allowSceneActivation = false;
yield return operation;
}
// Update is called once per frame
void Update()
{
//输出加载进度
Debug.Log(operation.progress);
}
}