Unity: Switch between scenes

Introduction

Switching between scenes is a basic task you want to achieve when developing your game in Unity. Here’s how to do so.

Prerequisites

  1. Unity game project (either 2D or 3D is fine)
  2. Two scenes: the tutorial below will guide you in creating the scenes
  3. Basic knowledge of C# programming

Steps

In this tutorial, I will teach you how to navigate from a Title Scene to a Game Scene. In the Title Scene, there will be a “Start Game” button. After the player pressed the button, it will navigate to Game Scene.

Select “Rename” to change the scene name
Click Reload
Add a UI button into the scene
The original camera area is at the lower-left corner (the tiny little rectangle)
Finally aligned with the Camera area
Looks basic now
Something like this
The default template for a Unity C# script
using UnityEngine.SceneManagement;
public void ClickStart() {
SceneManager.LoadScene("GameScene");
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class TitleSceneController : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{

}
// Update is called once per frame
void Update()
{

}
public void ClickStart()
{
SceneManager.LoadScene("GameScene");
}

}
Select the Main Camera as the object, then select ClickStart()
You can see all 2 scenes have been added to the Build Settings dialog

Completed Project

Completed Project can be download here.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Raptor Kwok

Raptor Kwok

I write stuffs: novels, programs, mobile apps, journal papers, book chapters, etc.