@[TOC](Slider Progress Bar Implementation)
Asynchronous Scene Switching with Progress Bar#
Working on it, I want to implement a scene switching function with a progress bar: here we use the UI component Slider to achieve this.
Specific Implementation:#
- Three scenes are needed: 【Menu】——【Loading】——【VRsubway】
- The SceneManager.LoadSceneAsync method can achieve asynchronous loading, meaning the current scene remains unchanged during loading.
- Use the AsyncOperation class to get the loading progress.
- Use the Slider component to display the progress.
Simple Setup of the 【Loading】 Scene#
【bg】image component, attach background image
【slider】progress bar component
【tips】tip information text
Code Implementation:#
Create Loading script:
Reference:
Define and initially start the coroutine:
Asynchronous loading:
Running Effect:#
Summary#
My understanding of this is still not thorough enough; the function seems to be implemented, but the effect may not be very satisfactory, as there is stuttering during loading, and I am currently unclear about the reason. I will explain it later when I learn optimization methods. Feedback is welcome!!!