using UnityEngine;
using System.Collections;
public class LoadScene : MonoBehaviour {
//异步加载的对象
AsyncOperation async;
void Start () {
// 执行协程方法
StartCoroutine (loadScene ());
}
IEnumerator loadScene () {
// 异步加载第三个场景
async = Application.LoadLevelAsync ("Running");
yield return new WaitForEndOfFrame ();
// 加载完成不自动进入
async.allowSceneActivation = false;
//5秒之后加载场景
yield return new WaitForSeconds(5f);
asynScene.allowSceneActivation = true;
}
void FixedUpdate () {
//打印异步加载场景的进度,加载完成时async.progress=0.9
Debug.Log(async.progress);
}
}