As follows:
Today has been tangled in how to load the scene, the middle of the loading screen and the effect of loading finished animation!
A scene to B, see online practice is a–> c–> B. C scenes are primarily used to asynchronously load B and play some animations of loading scenes
asyncoperation op = Application.loadlevelasync ("C"); Loading C scenes asynchronously
op.allowsceneactivation = false; Do not automatically jump to the B scene after loading (at the end of loading, you can play some loaded animation) when the animation is finished playing
op.allowsceneactivation = true; You'll be able to enter the B scene. O (∩_∩) o~
op.progress; gets the actual progress value of the asynchronous load scene (0-1)
usingUnityengine;usingSystem.Collections; Public classLoadsceneb:monobehaviour { PublicUISlider Slider;//progress bar voidStart () {loadgame (); } Public voidLoadgame () {Startcoroutine (startloading ("C")); } PublicIEnumerator startloading (stringscenename) {asyncoperation op=Application.loadlevelasync (scenename); Op.allowsceneactivation=false; /*actual progress is based on the scene loading, while (Op.progress < 0.9f) {slider.value = op.progress; The progress value of the actual loading scene is displayed in the slider. Yield return new waitforendofframe (); }*/ //since the C scene has only one picture loaded too fast, the following code simulates loading for(inti =0; I < -; i++) {Slider.value= I/100f; yield return NewWaitforseconds (0.01f); } slider.value=1; yield return NewWaitforendofframe (); Op.allowsceneactivation=true; }}
Unity Loading Scenarios Asynchronously