using UnityEngine;
using System.Collections;
public class Scene2 : MonoBehaviour {
//异步对象
AsyncOperation asyncOperation;
void Start () {
DontDestroyOnLoad(gameObject);
}
void OnGUI(){
//开始加载场景按钮
if(GUILayout.Button("Start Load Scene")){
StartCoroutine("loadScene","Bootcamp");
}
//判断异步对象并且异步对象没有加载完毕,显示进度
if(asyncOperation!=null&&!asyncOperation.isDone){
GUILayout.Label("progress:"+(float)asyncOperation.progress*100+"%");
}
}
IEnumerator loadScene(string sceneName){
yield return asyncOperation = Application.LoadLevelAsync(sceneName);
print("load Complete!");
}
}