using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using System;
using UnityEngine.UI;
public class Loading : MonoBehaviour
{
AsyncOperation async;
//自行决定
//UGU
public Slider m_pProgress;
//NGUI
public UISlider m_pProgress;
private int progress = 0;
// Use this for initialization
void Start ()
{
StartCoroutine(LoadScenes());
}
IEnumerator LoadScenes()
{
int nDisPlayProgress = 0;
async = SceneManager.LoadSceneAsync(GameDatas.Scenename);
async.allowSceneActivation = false;
while (async.progress < 0.9f)
{
progress = (int)async.progress * 100;
while (nDisPlayProgress < progress)
{
++nDisPlayProgress;
m_pProgress.value = (float)nDisPlayProgress / 100;
yield return new WaitForEndOfFrame();
}
yield return null;
}
progress = 100;
while(nDisPlayProgress < progress)
{
++nDisPlayProgress;
m_pProgress.value = (float)nDisPlayProgress / 100;
yield return new WaitForEndOfFrame();
}
async.allowSceneActivation = true;
}
}
场景:
简单的一逼,没啥可说的