- Home /
The question is answered, right answer was accepted
Button OnClick() calling wrong function
Hello, I am trying to make a button that will restart my game. When I press the button (screenshot attached) it should call RestartButton() which calls ButtonPushVisual():
public void RestartButton()
{
ButtonPushVisual(restartButton);
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
public void ButtonPushVisual(Button button)
{
button.transform.localScale = buttonPushScale;
}
When I press the button, it executes ButtonPushVisual() but not the rest of RestartButton(). I know this because when I put print statements around each statement, it called the ones in ButtonPushVisual() but not any in RestartButton().
I'm not sure what's wrong with it. I appreciate any help.
Answer by Eno-Khaon · Sep 16, 2018 at 07:25 PM
According to your screenshot, your UIManager script (bottom left) is calling the ButtonPushVisual() function (upper right), with the Button parameter filled by one you added in manually (bottom right).
Follow this Question
Related Questions
Upgrade Button 3 & 4 calling on the Upgrade 2 method 1 Answer
onclick.addlistener only works once 0 Answers
On Click Add Listener not working on Game Object 4 Answers
OnClick() animation 0 Answers