Asynchronous Scene Loading in Unity
Objective: Implement our loading screen while loading a new scene.
Now that we have our progress bar, we need some code to use it. We’ll being by including the UnityEngine’s SceneManagement and UI libraries.
When the Loading Screen scene starts, our progress bar will the LoadScene coroutine. This will begin an asynchronous operation to load our game scene. On every frame, we check to see if the loading is done (yield return null allows us to wait for a frame). If the scene is not yet loading 100%, our progress bar’s Fill Amount is set to the current amount of progress (from 0% to 100%). Once the game scene is full loaded, it takes over and our player can begin, well, playing!