How to Create a Loading Scene in Unity
When loading a scene you may find that it will take some time to load because of the amount of data the scene is trying to load. In this case, you should create a loading screen.
- Start by creating a new scene to create your loading screen in
- Create a canvas and add what you want to the scene. This should include an image that will be used as the loading bar
- Change the image type to filled
- Make sure your fill method is on horizontal
- Create a script on your canvas
- In the script make sure to use the UI and Scenemanagement namespaces
- Create a public reference to your progress bar image
- Create an IEnumerator that will use AsynceOperation to load the scene you want to load while you are on the loading scene. While it is not loaded you can set the fill amount of the progress bar to the progress of the asyncLoad progress.
- Start the coroutine in the start method
- In Unity drag the progress bar image into the script
- You will load the loading screen scene when you want to load the actual game scene. Like when you hit start game it will load the loading screen.
- Now you should have a working loading scene