the OnMouseDown function should do the trick, set a boolean to activate and deactivate the gui everytime the object is clicked , and you should be good
Ex:
var GUIActive : boolean = false;
var isGUIControl : boolean = false;//set this true for objects that control the gui
function OnMouseDown(){
if(isGUIControl){
GUIActive = !GUIActive;
}
}
and on the gui script you would use something like this
function OnGUI(){
var active : boolean = gameObject.GetComponent(//whatever you call that ^ Script).GUIActive;
if(!active) {
return;
}
//GUI stuff here
}