On the method of real-time updating of Unity3d asynchronous loading progress bar

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.