Unity: Loading scenes to restart the game
So our player has met an untimely demise. Let’s give them a way to try again and restart the level.

We start by adding instructions to press ‘R’ to restart the game in the form of a new Text object which we set to appear when the player dies. See this article for more info on this.
We also add a new empty object called GameManager and a GameManager script to assign to it.

The entire script looks like this. We have a bool, _isGameOver which defaults to false. In Update we look out for this bool to be true and for the ‘R’ key to be pressed, at which point we use use SceneManager.LoadScene() (remember to include using UnityEngine.SceneManagement; for this) and pass in scene zero which is currently our only scene. Finally we have a GameOver() method to set the bool to true when called.

In the UIManager script we add a variable reference to the GameManager and update our OnPlayerDeath() method to call GameOver().

In our build settings (File -> Build Settings) we need to make sure we have our scene added as scene 0.

Now when the player dies, we get the instructions for restarting and hitting the ‘R’ key will re-load the scene to start the level again.