Disable a GUI while left mouse button is Down?

Hello Everyone,

I’m trying to disable a GUI button while my left mouse button is down and dragging. I made this script but is not working.

Any idea what is wrong?

Thanks in advance!

static var showOff : int;

var Skin_360 : GUISkin;
var button360 = true;

 

function OnGUI(){

	GUI.enabled = button360 ; 
   	GUI.skin = Skin_360;
	if (GUI.Button(Rect(365,490,150,90),"")){
	}
	if (Input.GetButtonDown("Fire1")){
	 button360 = false;
	 showOff = 1;
	 }else{
	 button360 = true;
	 showOff = 0; 
 	} 
 	}

GetButtonDown() called once when button down.

Try this :

function OnGUI(){
 
    GUI.enabled = button360 ; 
    GUI.skin = Skin_360;
    if (GUI.Button(Rect(365,490,150,90),"")){
    }
    if(Input.GetMouseButton(0)){
     button360 = false;
     showOff = 1;
     }else{
     button360 = true;
     showOff = 0; 
    } 
    }

While in the OnGUI function you need to look at input events, not the input class.

Event e = Event.current;
if (e.keyCode == KeyCode.Mouse0)
    // return, gui == false, etc...

You could also just move your if (Input…) line to the update function and set a flag.