Sitemap
Tristan Engel

Tristan Engel

Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.

Loading Scenes in Unity

How to Restart the Game

May 20, 2021

--

To load Scenes in Unity through scripting we need to add the code library of SceneManagement at the top of our script:

Get Tristan Engel’s stories in your inbox

Join Medium for free to get updates from this writer.

using UnityEngine.SceneManagement;

To reload the current scene use the following code:

SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);

We also added some text so the player knows which button to press to restart. Be sure to add on check to see if the game is over or not, so the player can only restart when the game is over.

--

--

Tristan Engel
Tristan Engel

Written by Tristan Engel

Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.