120 Days to Master Unity (Day 8)

Brian Perry
3 min readMay 17, 2021

Loading scenes

One of the basic concepts of modern games is loading scenes. In this article, a main menu will be created that takes the player into the game scene where the game is played, when the player clicks on the start button.

The first thing to do is create a scene. This is easily done by right clicking on the scene folder and then selecting Create. From there, scroll down to Scene and click it. That will create a new Scene.

Once you have created a new scene, make a name for it like start screen. Next, select the new scene you created by double clicking it. You should see the familiar empty scene like when starting a new Unity project.

Now that you have a new scene, you can start making the scene more like a start screen by creating a picture for it like shown above. My background screen has the name of the game and a start button on it.

It also has a picture of the ship and a space background. With the picture that you want in the assets, just drag and drop the picture you want for the background from the project window into the hierarchy. From there, you can resize and anchor the image where you want it.

The most important part of all of this is the Start button. The start button will take the player from this scene to the game scene. The way that Unity does this is very easy and intuitive. All you need to do is first right click in the hierarchy window, select UI, and then click on button.

Once you create the button, all you need to do from that point is name the button a unique name so a script can be used to access it. Position it on the screen where you would like it to appear. Another important part is naming the button. For a game, it would usually say something like “Start Game”. The name can be easily changed in the text box. Just check it and type in whatever you want.

Like every other Unity entity you create, it usually needs an accompanying script to give it some sort of behavior. In this case, we want the script to jump to the game scene where we created the game when the user presses our start game button.

Like in the script above, you want the method that will be called with OnClick() to tell Unity to go to your actual game scene. To do this type, SceneManager.LoadScene(“scene-number”). Scene number is the number of the scene where you want to jump. For example: SceneManager.LoadScene(1). More than likely, your start screen will be scene-0 and the rest of your game will start at scene-1.

Once the script is created, the UI button game object is very easy to use. All you have to do select the button in the hierarchy to get the inspector for the button. Then simply select the method in the script you want to run for the OnClick() event.

Now, you should have a working button that takes you to the game when you click it!

--

--