A quick guide to loading scenes in Unity

Now the game is over what next? We need to provide a way for our players to start again. This is where scene management comes in.

Restarting a level can be as simple as loading the game scene. In order to load scenes however we need to make sure we import the correct library.

We are going to run logic that checks for when the “r” key is pressed (in the new input system). We only want the player to be able to use this action if the game is over so we will add this to our logic too.

Now we can load the scene a couple of different ways. First, we can do it by passing in a string “scene name” or using the scenes int reference.

We can find our scene int reference in our build settings. We can also arrange and add scenes here too.

I prefer to use a string to load a scene as we can ensure we will not have to change our scripts if they get moved around in our build settings.

And now we can see it in action.

That’s all for now.



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
Luke Duckett

Luke Duckett

Unity developer with a love of learning all things programming.