Free Loading Screen Manager Script
Published 4 years ago
1.2 K
How we built a simple free way to add a loading screen to your game
So, every good game needs a loading screen. The alternative is a black screen that gives the player no clue as to what happens and how long they have to wait. That’s just a plain bad idea, because it’s boring and it’s most likely going to make you fail console certification.
So, a loading screen was a must for Nowhere Prophet. But how do you build one in Unity? Well, I’ve spent some time looking into that and have a solution that might help you.
Here's a video explaining the basics. You can watch that first, then come back and get the details here.
First you need to actually create the scene that will be use as loading scene. It has to contain everything you need to show during loading. If you ask me, that means at least an animated loading icon, a visual for loading done, a progress bar and a short text. I’ve also added a black overlay to fade in and out for smoother transitions. You could simply add whatever you want. Maybe even build a loading mini game since that patent just expired…
For Nowhere Prophet I’ve built all of these visuals using the Unity UI system. Then I added the LoadingScreenManager to an empty gameObject and wired it to the scene so that it can access and update the visual elements. 
The visuals are the only part that’s specific to Nowhere Prophet with lots of helper components like a progress bar or a fader. I’ve done some simple replacements using basic Unity components there. You might want customize the last four methods to make your screen look a little less generic.
To use the loading screen in your game, all you need to do is call the static methodLoadingScreenManager.LoadScene(int levelNum). That will then load the loading scene you just built. Since it’s a small scene that should go quickly, and once that’s done the LoadingScreenManager in that scene takes over and loads the actual target scene you’re aiming for. That makes it pretty easy to use.
So, with all that said, here’s the LoadScreenManager script. 
Note that there’s also the option to load the scene additively or in single mode. Both options have a different feel for the user so it is up to you in the end.
Loading the scene additively allows you to simply switch it on once it’s done, which makes for a smoother transition but may cause some problems as you have both the loading screen and the target scene active together. For example with two AudioListeners being active (there’s a sorta hack that addresses this in the script).
Loading in single mode causes a bit of a black screen as the LoadingScreen is unloaded and the new scene is activated.
So, and that’s it for today. We got a bit technical there but I hope you enjoyed it. And as usual:
Stay hydrated,
Martin Nerurkar
Designer & Developer - Programmer