Asynchronous loading scenarios and loading progress bar making

Source: Internet
Author: User

When switching scenes, use application directly. Loadlevel () This method, if the load of the scene resources too much, will be stuck for a period of time.

So, with a transition scenario, the experience is a little bit better.

So let's start with a transition scenario (called: Loading). (like Jiangzi below, a picture of Baidu)

To switch the scene, Application.loadlevel ("Loading"), first switch to this Loading scene, Loading scene resources, on a background map and a slider, so, the direct synchronous loading came quickly

Then, write this script in the loading scene.

1  Public classLoading:monobehaviour {2AsyncOperation asyncoperation;//Asynchronous Variables3     PublicGameobject Slider;//progress bar4     PublicGameobject Text;//text on the progress bar5    //Initialize the above variables6    voidStart ()7{TenText.getcomponent<text> (). Text ="0";  OneProgress. Getcomponent<image> (). Fillamount =0f; A dontdestroyonload (gameobject); -Startcoroutine (Loadscene ());//Open Asynchronous task, enter Loadscene method -     } the     voidUpdate () -     { -Text.getcomponent<text> (). Text = (float) asyncoperation.progress* -+Ten+"%";//Text Update Asynchronous Progress -Progress. Getcomponent<image> (). Fillamount = (float) asyncoperation.progress+.1f;//Progress bar updates Asynchronous Progress +     } - IEnumerator loadscene () +     { A         yield returnAsyncOperation = Application.loadlevelasync (2);//automatic access to the next scene after reading at     } -  -}

Asynchronous loading scenarios and loading progress bar making

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.