Sitemap
Abner Carmona

Abner Carmona

Loading Scenes in Unity:

2 min readOct 1, 2023

Depending on the complexity of the game, you might want to divide it into different scenes. For example, one can create a scene for the game, and a scene for the main menu.

Press enter or click to view image in full size

Start by going into File> Build Settings… and press Add Open Scenes. Notice that Scenes/Game has the number 0. This can be used to reference and call that scene later.

Press enter or click to view image in full size

Create a “Game_Manager” object with a “GameManager” script. Follow it up by creating a new library called “UnityEngine.SceneManagement;”. After that, create a new bool called “_isGameOver” and set to false.

Then create a function called “GameOver” that changes the “isGameOver” bool option to true.

Get Abner Carmona’s stories in your inbox

Join Medium for free to get updates from this writer.

Now create an if statement inside of the void update function that only activates if the R key is pressed and the game over bool is set to true. This allows the scene to be loaded.

Head over to the UI manager script and add in a GameManager handler and place in the element the Game_Manager object. In start, find the game component script.

After that create a new function that will handle the game over sequence UI and change “UpdateLives” function to utilize the new function.

Press enter or click to view image in full size

--

--