public UIProgressBar loadingAnimator;
AsyncOperation async;
float displayProgress = 0f;
float toProgress = 0f;
// Use this for initialization
void Start () {
// 执行协程方法
StartCoroutine (loadScene());
}
IEnumerator loadScene ()
{
// 异步加载第三个场景
async = Application.LoadLevelAsync (3);
yield return new WaitForEndOfFrame();
// 加载完成不自动进入
async.allowSceneActivation = false;
yield return async;
}
void FixedUpdate ()
{
if (async.progress <= 0.9f)
toProgress = async.progress;
if (displayProgress < toProgress + 0.1)
displayProgress += 0.01f;
loadingAnimator.value = (displayProgress);
if (displayProgress >= 1)
async.allowSceneActivation = true;
}
打赏
扫一扫,请博主喝杯咖啡~
— 于 ,共写了410个字;
代码的语法高亮没了?这个排版格式没法看……
得手动改了。