banner
YZ

周周的Wiki

种一棵树最好的时间是十年前,其次是现在。
zhihu
github
csdn

Using Slider Progress Bar for Scene Switching in Unity Development

@[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:#

  1. Three scenes are needed: 【Menu】——【Loading】——【VRsubway】
  2. The SceneManager.LoadSceneAsync method can achieve asynchronous loading, meaning the current scene remains unchanged during loading.
  3. Use the AsyncOperation class to get the loading progress.
  4. Use the Slider component to display the progress.

Simple Setup for the 【Loading】 Scene#

Insert image description here
【bg】image component, mount background image
【slider】progress bar component
【tips】tip information text

Code Implementation:#

Create Loading script:

Reference:
Insert image description here
Define and initially start the coroutine:
Insert image description here
Asynchronous loading:
Insert image description here

Running Effect:#

Insert image description here
Insert image description here

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!!!

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.