Loading Scenes

Eric Philippot
2 min readJul 15, 2022

--

A start to every game.

Game loading screen, transitioning to game scene.
Loading Scenes

Working on the main menu. To do so I created a new scene.

Unity editor showing new scene in the project folder.
New Scene Called Main Menu

Then we have to add it to the build settings.

Unity build settings showing scenes that are available
Build Settings

Then we have to go to this scene and populate it with the main menu.

Unity Editor with game objects populated in the hierarchy to create main menu.
Main Menu

Those shown in red bracket is what was added. Next we move into a script called MainMenu after attaching it to the Canvas.

Main menu script that loads the next scene.
Main Menu Script

Here we import reference to the SceneManager and create a method called LoadGame(). We set it to public so we can have our button reference it and we call on the scene manager to load the scene at index of 1. This would be the main game scene we added to the build settings above.

Steps to add functionality to the Start Game button.
Pointing Button To Public Method LoadGame()

For this we take our button, add the game object with the script into the OnClick method and then search for our LoadGame() method in the MainMenu script.

Now at game play, this button will load the game scene and we are good to go. You can see in the script I also created an input called start which maps to the Xbox one controllers start button. For windows anyway. I read that its a different index on some other platforms like android.

Input menu with added joystick button 7 called start.
Start Input For Xbox Controller On Windows

--

--

Eric Philippot

Game and Web Developer with a joined experience of 6 years.