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...

Web

Behind the Scenes of a Web Development Project

When you visit a finished website, you only see the final result: clean pages, smooth animations, well-organized content. But behind this facade lies a far more complex creation process, made up of strategic thinking, technical decisions, and collaboration between...

Blog image

Essential Tools Every Web Developer Needs

The web development profession is constantly evolving, and with it, the tools needed to work efficiently. Between code editors, frameworks, debugging tools, and deployment platforms, the choices can feel overwhelming for beginners and experienced developers alike who...

Recreate Snake in HTML and vanilla JavaScript

Recreate Snake in HTML and vanilla JavaScript

Sometimes the best projects come into being without any particular pretension, just for the pleasure of coding and diving back into video game classics. That's exactly the spirit behind this retro version of Snake, built entirely with HTML and vanilla JavaScript, with...

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.