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

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)

you may need to use extra combinations depending on the 'shape' of your GUI