- Home /
OnClick button does not work? Trying to make a pause menu
So I have a Pause Menu and for my resume button I have the following code:
(fps.GetComponent("MouseLook") as MonoBehaviour).enabled = true;
pauseCanvas.enabled= false;
Time.timeScale = 1;
Screen.lockCursor = true;
Cursor.visible = false;
But once I try to click on the resume button during runtime, the game does not resume. The pause menu is attached to canvas whereas the script of the pause menu is on the main object. and I have an eventsystem and graphic raycaster on my canvas. What could be wrong?
Answer by Rhylvin2015 · Jul 28, 2015 at 09:47 AM
try to debug your Resume add
Debug.Log("Resume");
and if you click your Resume Button that should pop up in your console. if not there is problem with your button.
I tried this and the message didn't show up in the console.
then there is problem with your button... when you click it nothing happens because the script that you made didn't connect
I tried using another button and that didn't work either :/
Answer by rohankad · Jul 28, 2015 at 12:37 PM
Are you using the new Unity UI. If yes, then on the pause button go the on Click (). Click on +, add the gameobject which has the script. From the drop down, select the method you need to call.
The next thing to is:
Set the TimeScale to 0. [ Time.timeScale = 0 ;]
Enable the Pause panel.
Yes i'm using the new Unity UI and yes the script is selected from the main gameobject. The pause panel is also enabled and the timescale = 0 for pausing the game. Not sure what else to do
Your answer
Follow this Question
Related Questions
Pause-Resume one button using switch statements? 1 Answer
NGUI Button Click Callback from external script. 2 Answers
Canvas button with 2 functions onClick must be pressed twice for 2nd function? Will not disappear? 1 Answer
How to ADD one Buttons.onClick events to another Buttons.onClick? 1 Answer
button OnClick function triggering another buttons OnClick 0 Answers