Learn to make cutscenes in unity3d by building a stealth Game.

Suleiman Abdullah
3 min readOct 10, 2022

--

Objective: Challenge Menu Functionality.

In the first step create a script called the main menu and attach it to canvas.

Create two public methods one for quitting and one for restarting the game.

To start the game we will need to call the “SceneManager.LoadScene”, we do this by passing the name of the first level which is “ Main”.

Note: The name parameter is case-sensitive.

When we want to quit the game when we press the quit button, we do this using the application dot quit method.

Select the Main menu button then add events to each button, and drag and drop the Main Menu object to the object field of the event of each button. Last, select the function of each button and save the scene.

Open Build Setting and add the main menu to the build window.

Note: Make sure the main menu is the first one because when you play the game it starts to open the scene with build index zero which is the first one, so we need to make sure the main menu is the first scene in build Setting .

If you play as this nothing will work, can you guess what the problem is?

I put debug in the script to make sure my method gets called ?, Sadly it did not!

To solve this let's understand what makes a button or UI object interact able, it's an event system. When we create an image for the first time unity didn't create an event for us we didn't think about it, why Suleiman???.

I choose this root plus button at hierarchy UI <Event System, it will create event and canvas, delete canvas we want event system.

Note: The tab to create event is not necessary to follow my way

This is how I solve this challenge.

See you next article

--

--

Suleiman Abdullah

Self taught Unity Developer, who is passion about making games ,and he loves Math For Game Development