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!