SceneManager.LoadScene does not load the game scene

I really don’t know why my SceneManager.LoadScene does not load the game scene. I have two scenes, Game and MainMenu. In MainMenu I have a Canvas and a Text on it. I added a Button component.

I have a GameMaster C# script:

using UnityEngine;
using UnityEngine.SceneManagement;

public class GameMaster : MonoBehaviour
{
public void GoToGameScene()
{
SceneManager.LoadScene(1);
}
}

I created a new Empty Object in MainMenu scene, renamed it to GameMaster. I added the GameMaster script to it and then I added the GameMaster object to the Play button on Click. I selected the GameMaster.GoToGameScene method for the on Click.

When I run the game, the button click does not open the Game scene.

  • Check for any errors in your console
  • Add Debug.Log statement to your GoToGameScene method to make sure your code is actually running
  • Check your build settings and make sure the scenes you care about are in the list and with the indexes you are expecting them to have.