How do I make GUITextures not rendered by cameras with the highest depth clickable?

Dear all,

I have the following scene.

29762-unity-depth-question.png

There are two cameras in the scene. Camera1 with depth 0 renders UnityLogo1 (normal colour), and Camera2 with depth 1 renders UnityLogo2 (red). Because Camera2 has a higher depth than Camera1, you can see that the red logo is overlaid on the normal logo.

Now, the problem is, it turns out that I can only click the red logo, but not the normal logo. So when I attach the following script to both logos,

using UnityEngine;
using System.Collections;

public class Click : MonoBehaviour {

	void OnMouseDown () {
		Debug.Log (gameObject.name);
	}
}

and click both logos alternately, only “UnityLogo2” is printed.

My guess is that, this happens because the normal logo is hidden behind the frontmost “layer”, where the the red logo is rendered. So my question is, is there a way to make the normal logo clickable even if it is not in the frontmost “layer”, i.e. not rendered by the camera with highest depth layer?

Thank you!

I found a workaround myself, although it does not work 100% as I wanted.

The key is GUITexture.HitTest. I modify the Click class as follows.

public class Click : MonoBehaviour {
    
	void Update()
	{
		if(Input.GetMouseButtonDown(0) && gameObject.guiTexture.HitTest (Input.mousePosition))
		{
			Debug.Log ("Update: " + gameObject.name);
		}
	}
}

And now I can click UnityLogo1 too. However, if I click the are where UnityLogo1 and UnityLogo2, both logos are clicked.