The exercise here demonstrates implementation of loading scene in Unity.
There are high chances when a heavy 3D model needs to be rendered completely before a new scene begins and that may delay the start of the game.
In order to not loose out on the engagement of the player, there must be something better on screen than a delay. We all have been seeing the loading screens ever since we sat in front of the computers and that is the idea solution for most cases.
To deploy it, there are a few inhouse methods could be utilized.
In technical terms, Unity calls it an asyncoperation.
What is being checked here?
Whether the scene which should have been loaded instantly, is actually rendered successfully (This would vary largely depending on the hardware configs at the player’s end). Upon verifying this, it is assured that the game would not lag as soon as it starts for rendering reasons.
Here is a new scene made in the same project with a few UI elements.
What is the target the hook here?
The yellow progress bar shall only increase its coverage based on the rendering state of the next scene, which happens to be the “Main” scene.
The fill amount, if sent back to 0, the yellow bar would disappear.
The task is to use methods of async operations from Unity and hook this successfully.
- First, the loading bar element is referenced.
- Second, the start method initiates coroutine.
- Third, the coroutine assigns the “Main” scene to the asyncoperation variable.
- There is a method “.isDone” which returns bool value depending on the actual progress status.
- As soon as the return turns to true, the coroutine ends after waiting for one frame.
That should be it :)
Here is the final result.
Thank you very much