Loading a Scene in Unity

Bradley Yachimowski
2 min readMay 16, 2021

In order to load a “Scene” in Unity, we first have to create one. By default, Unity creates the first scene for you. So let's create another “Scene”.

Let’s rename our new scene to “Main Menu” and put it in our “Scene” folder.

Drag and drop the newly created “Main Menu” scene into the previously created “Scenes” folder.

The next step is to add our scenes to the “Build Settings”. Build Settings also assigns a reference number to our scene. Since we have two scenes, the first one is assigned “0” and the second is assigned “1".

Both scenes were already added in the example above. There is an option to “Add Open Scenes” if you use this method make sure your scenes are added in a “Logical” order, for example, Level 1, Level 2, Level 3…

To call a “Scene” from a C# script we have to first add the “Scene Management” library to the Header of our C# script. We do this by adding using UnityEngine.SceneManagement;” to the top of our script. Once the new library is added we can load the “scene” by (“name”) or by reference (1)

In the code above we load Scene “1” which is the reference number assigned in the “Build Settings” We could have also used the code “SceneManager.LoadScene(“Space Shooter”);”. I like to use numbers for a reference because it takes less time to process an integer than it does to process a string of characters. Well, that is all there is to “Loading a Scene in Unity”. Until next time…

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response