Replay Button not working

Jun '22 - Unity 2D - Quiz Master - Game Manager. I have re-checked my Game Manager script several times and also tried re-adding the Replay Button, but button still not working. Have attached script and button print screen. Any help is greatly appreciated! Thank you in advance!


Hi,

For testing purposes, disable the Quiz Canvas and test your button again. Maybe the elements on the other canvas or something else is blocking the raycast of the mouse which is supposed to hit the “Play Again” button.

Hi,

Thank you. After I disabled the Quiz Canvas (unchecked in Inspector) and hit Play, the button would not work and I got the error message:

NullReferenceException: Object reference not set to an instance of an object
GameManager.Update () (at Assets/Scripts/GameManager.cs:26)

In my GameManager.cs, line 26 is under void Update, if(quiz.isComplete). isComplete is a public bool in my Quiz.cs.

If you disable the Quiz Canvas, error messages are expected. What we want to figure out is if the button is able to log a message into your console if there are no game objects preventing the raycast of the mouse from hitting the button. For testing purposes, you could also define an eye-catching colour for the “Highlighted Color” in the Button component. On mouse over, your button should change its colour. If it does not, the button itself did not work.

Also check the Canvas component to which this Button is connected. “Block Raycast” must be enabled. It might be that the field is called “Receive events” now. See here.

Thank you very much! I learned a lot from your help. The problem turned out to be that the Canvas sort order was too low (embarrassing). Thank you, again!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms