using System.Collections;
public class AsyncLoad01 : MonoBehaviour {
// Use this for initialization
void Start () {
//返回当前场景的索引
print ("LoadedLevel:"+Application.loadedLevel);
//当前场景的名称
print ("loadedLevelName:"+Application.loadedLevelName);
//检测此场景是否正在加载,加载完是返回false,正在加载时返回true
print ("isLoadingLevel:"+Application.isLoadingLevel);
//返回当前可加载的场景数量
print ("LevelCount:"+Application.levelCount);
//检测游戏运行平台:手机,电脑,游戏机,可在枚集类RuntimePlatform中查看
Debug.Log ("platform:"+Application.platform);
//当前游戏是否正在运行
print ("Isplaying:"+Application.isPlaying);
//当前游戏是否处于unity编译模式
print ("isEditor:"+Application.isEditor);
}
// Update is called once per frame
void Update () {
}
}
using UnityEngine;
using System.Collections;
public class Scene01 : MonoBehaviour {
private AsyncOperation asy;
public UISlider slider;
// Use this for initialization
void Start () {
if(slider){
slider.value = 0;
}
StartCoroutine (loadScene());
}
// Update is called once per frame
void Update () {
print (asy.progress);
if (asy.progress < 0.9) {
slider.value = asy.progress;
} else {
slider.value = 1;
}
// if(Input.GetKeyDown(KeyCode.A)){
// //Application.LoadLevel ("Scene02");
// //Application.LoadLevelAdditive ("Scene02");
// Application.LoadLevelAsync ("Scene02");
// //Application.LoadLevelAdditiveAsync ("Scene02");
// }
}
IEnumerator loadScene(){
asy = Application.LoadLevelAsync ("Scene02");
print (asy.progress);
yield return asy;
}
void OnDestroy(){
print ("Scene01 Destroy");
}
}