In other places to see the so-called real-time update is to let the current value of the slider is equal to the progress of the asynchronous object, it is too pit, this normal to understand the meaning is not to start from 0 to 100, no matter how I have finished this function, code affixed, so as not to forget later, The friend who found this blog is lucky for you, just move it (Ngui version) ~
It is important to note that the value of asynchronous object AsyncOperation will not grow after 90%, the remaining 10% To let asyncoperation.allowsceneactivation (meaning that the scene automatically jumps after loading) is true, it will be completed automatically ~
The complete code is affixed below:
Using unityengine;using System.collections;public class Loading:monobehaviour {private AsyncOperation async;public UISlider slider;//Use this for initializationvoid Start () {Startcoroutine (Loadscene ());} Update is called once per framevoid 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;}
On the method of real-time updating of Unity3d asynchronous loading progress bar