GUITexture and Onmousedown detection

Hi everyone, I have a menu set up with a panel on the right which opens as various options are chosen: New Game, Load Game, Options etc.

For resetting the information when the background is clicked, or another menu button (which calls up that menu’s information into the right hand panel) is there a way of detecting an Onmousedown NOT on that GuiTexture object to trigger the guitexture.enabled = false part of my code?

Here is an answer I consider a hack because it depends on the order that Update() and OnMouseDown() is called, and I’ve never seen the order documented. Since OnMouseDown() gets called first (empirically), we can record the frame number. Then we can use GetMouseButtonDown() and check this value to see if the click is inside or outside the GUITexture:

#pragma strict

private var onMouseFrame = -1;

function Update () {
	
	if (Input.GetMouseButtonDown(0) && Time.frameCount != onMouseFrame) {
		Debug.Log("Clicked outside of the GUITexture");
	}
}

function OnMouseDown() {
	onMouseFrame = Time.frameCount;
}

And here is the same concept implemented a bit differently…easier to understand but just a bit less efficient:

pragma strict

private var onMouseDownThisFrame = false;

function Update () {
	if (Input.GetMouseButtonDown(0) && !onMouseDownThisFrame) {
		Debug.Log("Clicked outside of the GUITexture");
	}
}

function OnMouseDown() {
	onMouseDownThisFrame = true;
}

function LateUpdate() {
	onMouseDownThisFrame = false;
}