Loading Screen

How to create a loading progress bar in Unity

Tristan Engel
2 min readOct 15, 2021

In this article we will create a loading bar animation based on the progress of loading.

To do this we will be using AsyncOperation.

Since we are loading scene and using UI we need to add the extra libraries.
We created a handle to the progress bar UI image and assigned it from the Inspector.

On the Image we set:
Image Type > Filled
Filled Method > Horizontal

In the start method we start the coroutine to load the level async.
The coroutine starts loading the level async and assigns it to a AsyncOperation type variable. Then we can access whether it’s done with .isDone and also get the progress with .progress.
While the asyncOperation is not done we keep changing the UI image fill amount using the asyncOperation progress each frame. The waitforendofframe prevents the machine to overload.

using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class LoadLevel : MonoBehaviour
{
public Image progressBar;

void Start ()
{
StartCoroutine(LoadLevelAsync());
}

IEnumerator LoadLevelAsync()
{
AsyncOperation asyncOperation = SceneManager.LoadSceneAsync("Main");

while (asyncOperation.isDone != true)
{
progressBar.fillAmount = asyncOperation.progress;
yield return new WaitForEndOfFrame();
}
}
}
PC loads too fast for nice smooth fill of progress bar

--

--

Tristan Engel

Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.