标签:
在其他地方看到所谓的实时更新就是 让slider的当前value等于异步对象的进度值而已,太坑了,这个正常来理解的意思不就是从0开始递增到100嘛,不管怎么我已经完成这个功能了,代码贴上,以免日后忘记, 找到这篇博客的朋友算你好运,直接搬走吧(NGUI版)~
需要重点提醒的:异步对象AsyncOperation的值到90%后不会再增长,剩下的10%要让AsyncOperation.allowSceneActivation(意思是场景加载完毕后自动跳转场景)为true时才会自动完成~
完整代码下方贴上:
using UnityEngine; using System.Collections; public class Loading : MonoBehaviour { private AsyncOperation async; public UISlider slider; // Use this for initialization void Start () { StartCoroutine (loadScene ()); } // Update is called once per frame void Update () { if (async != null) { if(!async.isDone) { if(slider.value<=.9f) { if(slider.value <= async.progress) { slider.value += Time.deltaTime; } } else { if(slider.value<1f) { slider.value += Time.deltaTime; } else { async.allowSceneActivation = true; } } } } } IEnumerator loadScene() { async = Application.LoadLevelAsync (Globe.loadName); async.allowSceneActivation = false; yield return async; }
标签:
原文地址:http://www.cnblogs.com/hellozzz/p/4621608.html