Buttons: Using OnClick() to Change our Scene | Unity 2D

Chelsea Cruise
2 min readJun 29, 2021


Objective: Load our game scene from the main menu using a button.

On the button game object, create a new script. I’m calling mine ‘Main Menu’. Attach this script to your button.

In our script we will need to make sure to add the using UnityEngine.SceneManagement; to the top of our script.

Next, create a public method called Load Game(). This will be responsible for changing our scene.
We will then inside access the SceneManager.LoadScene() and pass it an index of 1.

You can find the index by going to File > Build Settings. If you don’t see your game scene in the menu, click and drag it into the Scenes In Build menu.

Back in our button inspector, you will see OnClick(). This will be responsible for adding the functionality to our button.

Next, add your Canvas to the empty game object field. In the function drop down menu, this will be where we access the script we just made called Main Menu. We then want to access the LoadGame() method.

NOTE: If you are unable to find your LoadGame() method, go back to your script and make sure you made it public. i.e., public void

We now have a fully functional button that we can now add to our main menu and have it take us to our game scene!



Chelsea Cruise

Unity Developer, Software Engineer, Game Designer, Graphic Artist