Making a loading screen in between Levels is Unity3D

Loading is one of the most considered thought while making Levels. We always have to be careful so as not to make our levels too heavy. Long loading makes the user bored from the game resulting in simple uninstallation or bad review. Though there are many ways by which we can optimize the game in order to make it load faster.
Whatver the case may be, it is always a good idea to make a loading screen to appear in between levels so as to make the user aware that the game is working on loading a screen rather than giving an appearance where it seems that the game has just freezed.

As with my progress in my current game I had to make a similar loading screen and was totaly unaware of how to do it in Unity3D. I have a experience in making games for Flash and it was pretty simple in Flash. After doing little experiment of my own I found that, in Unity too its as simple as making a seperate scene and just arranging the screen in a similiar fashion.

Following is the little guide on how to make a Loading Screen in Unity3D:

– Make a blank screen and add the content you want to to appear as a loading screen. For example, a small animation or a simple textured image giving a description of loading. The way to make it more attractive is by giving some hint or background story of your game. (Just play some PC/Console Games and you will come up with variety of ideads :D)
If you want different kind of loading screen between each levels then you will have to make all as a seperate scene.
[Make sure that this scene is very small to load or there is no point of making this scene 😛 ]

– Its a good idea to make a “EmptyGameObject” and then add the following JavaScript.


var levelName : String;

function Update ()
{
if(Application.GetStreamProgressForLevel(levelName) == 1)
{
Application.LoadLevel(levelName);
}

}

– Now after adding this to the EmptyGameObject in each loading screen just change the name of the ‘levelName’ to the Actual LevelName from inside Unity Inspector. The benefit of doing this from here and not from script is that you can use the same script in all the Loading Scenes and can have differnt level names in Inspector. If you try to do this by script then you will have to make seperate scripts for each Load Scenes.

– Now when Publishing make sure to arrange the Scenes accordingly so that LoadScreen appears in between all the levels and you are done.

Thanks for your valuable time.
Do contact me if you have any problem in understanding or following the instruction. Also would appreciate if someone could share a better way to do it 🙂

    • Girish S
    • May 3rd, 2013

    can you give an example to explain this. ‘m not understanding how “Application.GetStreamProgressForLevel(“levelName”)” this works..

  1. Hi Girish,
    Please follow step by step instructions as mentioned in my blog. However let me explain it you one more time.

    1> The “levelName” is a String variable which will store the name of the level you want to stream and load.
    2> “Application.GetStreamProgressForLevel” will stream and load that particular level in memory and as its done loading it in memory, it will then automatically go to its next line of code which is to load that level in the game.

    • haonv
    • June 18th, 2013

    I don’t know how to loading runing when scene not call 😮

    • Liv
    • September 8th, 2013

    So if I understand, I should have 3 scenes. They are the Menu_Scene, the Loading_Scene, then Level_1 of my game. When the player hits START in the Menu Scene, should it call Application.LoadLevel(Loading_Scene) or Application.LoadLevel(Level_1) ? I’m confused because the code you included above makes it look like the Loading Scene does not call to load the next scene.

    • Well.. When the player hits the START in the menu Scene, it should call the loading scene. Now Loading_Scene will have the code that you found above in my post and that code has a String Variable called levelName. levelName is the name of the level, which in your case is Level_1, so when the loading _Scene is called it will stream the Level_1, load it in the memory and when that is done it will load the Level_1 in the game.
      Of-course the reason we are doing this is because incase your Level_1 has lots of assets or textures in it it will take some time to load depending upon the device and RAM the device has. If we dont include the Loading scene then after the player clicks START, player will still see that same Menu scene until the the next scene has loaded and might confused that the game is stuck and so might tap/click the START again over and over, which is not very good user experience.

  2. I made it like this, but my loading screen starts only about a half a second before my scene1 is loaded, and in the meantime i have a “freezed” scene. :/
    So what could be my problem?

  1. No trackbacks yet.

You must be logged in to post a comment.