- Home /
Pausing issue with OnMouseDown
I have several gui textures in my game and the following pause/restart script is on one of the buttons just to toggle on and off. However the script works when the mouse is clicked anywhere. I know it means I have to replace Input.GetMouseButtonUp(0) with function OnMouseDown but how do I do it? Getting too many errors. I know it’s a simple thing but I can’t find the answer.
var paused : boolean = false;
function Update () { if(Input.GetMouseButtonUp(0)){ if(paused == true){ paused = false; } else { paused = true; }
if(paused == true){
Time.timeScale = 0.0;
} else {
Time.timeScale = 1.0;
}
}
}
Comment
Answer by Ngoc Ngo · Jul 07, 2014 at 09:46 AM
You don't have to use OnMouseDown, make a GUILayout.Toggle like this:
m_isPaused = GUILayout.Toggle(m_isPaused, "Pause!");
Your answer
![](https://koobas.hobune.stream/wayback/20220613153410im_/https://answers.unity.com/themes/thub/images/avi.jpg)