@[TOC](Slider Progress Bar Implementation)
Asynchronous Scene Switching with Progress Bar#
Working on it, I want to implement a scene switching feature with a progress bar: here we use the UI component Slider to complete it
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 for the 【Loading】 Scene#
【bg】image component, mount 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#
I don't fully understand this yet; the functionality seems to be implemented, but the effect may not be very satisfactory. There is a stutter during loading, and I can't figure out the reason for it at the moment. I will explain it later when I learn optimization methods. Any guidance is welcome!!!