- Home /
Ignore GUI Clicks in Game
Hello, basically my game consists of a car with a gun and some GUI. Whenever I click on any GUI (whether it be a button or a text field) the gun fires. Is there a way to ignore the GUI clicks while playing?
Oh, one more thing - I am using OnGUI functions to display my GUI.
Thanks In Advance, CarbonTech Software Admin
Answer by cncguy · Jul 10, 2010 at 09:26 PM
You can check whether the mouse is inside the area of your GUI by using Input.MousePosition
eg. If your GUI input is at the top of the screen, on a mouseclick check it before letting it fire your gun:
if(Input.MousePosition.y < Screen.height - 50)
FireWeapon();
you may need to use extra combinations depending on the 'shape' of your GUI
Thanks! I didn't think it would be that simple...
Your answer
Follow this Question
Related Questions
Player Fast Travels 1 Answer
GUI on click 2 Answers
click on GUI button goes through to a collider... 0 Answers
Prevent mouse click through GUI Texture?!?! 0 Answers
Let Click go through GUI 1 Answer