Unity asynchronous loading scenario loading entries

Source: Internet
Author: User
Using unityengine; using system. collections; public class loadingscene: monobehaviour {public uislider processbar; private asyncoperation async; private uint _ nowprocess; // use this for initialization void start () {_ nowprocess = 0; startcoroutine (loadscene ();} ienumerator loadscene () {// asynchronous read scenario. // Globe. loadname is the name of the C scenario to be read in Scenario. Async = application. loadlevelasync (globalvaule. loadlevelname); async. allowsceneactivation = false; // after reading is completed, the system automatically enters the yield return async;} void Update () {If (async = NULL) {return ;} uint toprocess; debug. log (async. progress * 100); If (async. progress <0.9f) // progress ss of the potholes, up to 0.9f {toprocess = (uint) (async. progress * 100);} else {toprocess = 100;} If (_ nowprocess <toprocess) {_ nowprocess ++;} processbar. value = _ nowprocess/100f; If (_ nowprocess = 100) // async. isdone should be true {async when the scenario is activated. allowsceneactivation = true ;}}}

It's relatively simple. I directly went to the code and commented out some of the pitfalls ~

Unity asynchronous loading scenario loading entries

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.