Unity 3D: how to change scenes?

March 27 2026

Today we're going to talk about one of the basic concepts of Unity 3D, software that allows you to create video games.

We're going to see how to change scenes.

It's really simple. First, you need to create a C# script, which I'll call for example ChangeScene.cs.

The first thing to do is import the SceneManagement class:

using UnityEngine.SceneManagement;

After that, we start building our script by creating a variable:

public string LevelToLoad;

We're almost done. What remains is to write a function that loads the content of our variable:

void LoadLevel()
{          
   SceneManager.LoadScene(LevelToLoad);
}

Once done, you'll need to type the name of the scene to change in the empty field of the script that you'll attach to the GameObject, in my case "MainMenu".

Unity3D - Change scene

What remains is to trigger the event in the animation by going to "Animation" and clicking on the small white "Add Event" button.

Unity3D - Change level

If, on the other hand, you'd prefer to put the scene name directly in your script, you could do it this way:

void LoadMenu () {           
    SceneManager.LoadScene("MainMenu");
}

Obviously MainMenu is the name of an already created scene.

Here is the complete script:

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class ChangeScene : MonoBehaviour {

    public string LevelToLoad;

    void LoadMenu () {
        SceneManager.LoadScene("MainMenu");
      }

    void LoadLevel()
    {
        SceneManager.LoadScene(LevelToLoad);
    }

}

IMPORTANT: for this to work, your scene must be present in the Build Settings of your game.

Unity3D - Build Settings
File > Build Settings

Your turn to play!

Sudoku Quest

Itamde courses

Recent Posts

Recent Comments

"

Itamde is also an online programming school.

Itamde

Learn what you want, at your own pace

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

You may also be interested in...

Stay up to date with the latest news and developments

Access restricted content

Discover behind-the-scenes details of our projects, exclusive resources, and the progress of our creations in real time.

Sign up for our newsletter

Receive our news, creative insights, and updates from the studio directly in your inbox.

Follow us

Join our community on social media to follow our daily projects and interact with us.