HitTest for GUI.Button

Is it posible to know the GUIElemnt (GUI.Button) under the mouse???

I have a GameObject with a script:

if (Input.GetButtonDown("Fire1")){
    print("do stuf");
}

an other ‘unrelated’ GameObject(Camera.main) creates the button :

void OnGUI(){
 if (GUI.Button (new Rect(20,40,80,20), "Button")){
	print("BUTTTON PRESS");
 }
}

the idea is to NOT have the first script fired when i press the button.

I could use the Texture Layer and create button old style … and then use the GUILayer.HitTest. but i realy would like to use the UnityGUI.

Its not possible to directly check if mouse is over GUI element, but you can store the Rect you use for displaying the element and then do this:

Humm not exactly what i was hoping for, but i guest it will have to do.

How would I use that with DragWindow ???

You can get the rect’s top-left corner by adding the window’s corner to the element’s top-left offset within the window.