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…

Artificial intelligence is reshaping every pixel

Artificial intelligence is reshaping every pixel

Just a few years ago, editing a photo meant spending hours working meticulously in Photoshop, mastering layers, masks and curves. In 2026, everything has shifted. AI photo editing tools no longer settle for automatic filters — they understand image content, anticipate...

The 10 Best Free AI Tools for Developers in 2026

The 10 Best Free AI Tools for Developers in 2026

Artificial intelligence is transforming how developers write, test, and deploy code. In 2026, many AI tools are freely accessible, offering capabilities that would have seemed impossible just a few years ago. Whether you're a beginner or experienced developer, these...

CSS colors

CSS colors

CSS colors can be defined in hexadecimal. Hexadecimal uses three components: red, green, and blue. You can define colors in shorthand hexadecimal: for example #DC2 corresponds to #DDCC22. Note that some colors cannot be abbreviated. The goal is to shorten your...

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.