Unity 3D - Loading Levels in Unity 5.3 Posted on December 08, 2015

Welcome Unity 3d 5.3!

First off I am super excited to start to play around with Unity 3d 5.3; I have an asset that I need to finish and put up to the asset store. I wanted to do some work on it, so I opened up my asset to be greeted with the warning

Assets/Scripts/SplashManager.cs(157,37): warning CS0618: `UnityEngine.Application.LoadLevel(string)' is obsolete: `Use SceneManager.LoadScene'

Well if this is news to you, like it was to me you are probably wondering how you can load levels without generating a warning (and in future versions load levels).

Say hello to the Scene Manager

The Scene Manager is Unity's new way of loading levels. It allows you to split your level up into multiple scenes and have it load them when the player is close to them (or all at once). Anyway, let's not get off topic here. Unity is deprecating the Application.LoadLevel(); and we need a new way to load the scenes.

You can follow these two very simple steps to get your levels loading in Unity 3d 5.3 and higher.

New namespace

First we need to add the new namespace into our older projects. At the top of your script, add the following

using UnityEngine.SceneManagement;

New command

Next we need to change our Application.LoadLevel(string); to the following code

SceneManager.LoadScene(string);

That's it?

You bet! Nice and simple. Happy coding!

Share this post