Check if GUI button if released

Is there a way to check if a GUI button is released?

I can only think of a syntax to check if a GUI button is pressed but i need to check if a gui button is released also.

This is what i have so far:

if (GUI.Button(new Rect(Screen.width / 4 * 3.5, Screen.height / 1.2, 100, 100), "shoot")){
    // The button has been clicked
    Debug.Log ("ButtonGUI Clicked");      
    //Shoot.Schietkogel();
}

I had a hard time trying to solve this same problem today! You must use a RepeatButton instead - but this bastard actually returns true and false alternately each OnGUI when pressed! The solution is to use a boolean flag that’s set when RepeatButton returns true, and reset when the mouse button is released:

private var buttonDown = false;

function OnGUI(){
  if (GUI.RepeatButton(new Rect(...), "shoot")){
    buttonDown = true; // RepeatButton only sets buttonDown
  }
  // and buttonDown is reset only when the mouse button is released
  buttonDown &= Input.GetMouseButton(0);
  // use buttonDown to know the current button state
}

GUI.Button will return true if the mouse was pressed and released hover the rect. The mouse can be moved in between, as long as the mouse’s button isn’t released.

So actually, GUI.Button already detect if it was released.