- Home /
Disable Mouse Input when OnGUI()
Is there an easy way to disable mouse input when the function OnGUI() is called? I know I can flip a bool when the function is called, however, there is no OffGUI() function to reset the boolean value when the mouse isn't on a GUI. Whats happening now is that I left click on the GUI but it still does the other scripts on left click due to IfMouseButtonDown(0) being triggered in the Update loop. Any ideas to disable mouse clicking when hovering on a GUI?
Answer by DaveA · Apr 02, 2011 at 12:20 AM
Set a global boolean if the mouse is inside the GUI's window. Then check that value in any script that looks for mouse-downs, to ignore if that boolean is set (meaning, if the mouse is over that GUI window).
Your answer
Follow this Question
Related Questions
Can I change GUIButton behaviour? 1 Answer
Buttons that remove themselves when clicked mess up other gui elements 2 Answers
How to fire gui button on mouse right release 2 Answers
GUI texture to change texture when hovered over or clicked? 2 Answers
Using a GUI.Button to Instantiate gameObject using another gameObject's location 1 Answer