Help, script/button doesnt work

Basically, fade transitions between scenes in my project.There are no errors but when i test it, the button does nothing. No errors pop up when pressing the button, i dont know what to do. Any help on this?

    public string sceneName1 = "";
    public Animator Fadey1;

     void Update(){

        if (Input.GetButtonDown(GameConstants.k_ButtonNameCancel)){
              StartCoroutine(LoadScene());
         }
      }


     IEnumerator LoadScene(){
     
        Fadey1.SetTrigger("Start");
       
       yield return new WaitForSeconds(1);

        SceneManager.LoadScene(sceneName1);
   }
}

First step when you don’t know what’s going on is to litter your code with Debug.Log() statements. Put one in Update before the if statement to make sure update is running. Put one inside the if statement to make sure your button press is being detected. Put one inside the coroutine to make sure the coroutine is starting properly, etc…

You will get a much better understanding of what’s going wrong this way. Then there will be less guesswork involved in the solution.

This is the BEST ADVICE to quickly solving weird failures in the code. Find out where your code is running. None of us can do it. You can do it. We know you can. :slight_smile:

I put one in the Update() and one after button click, it doesn’t respond when clicking the button

Ok, so what’s the value of GameConstants.k_ButtonNameCancel?

what do you mean by value?