- Home /
It seems to me that if I click on a GUITexture the click event is captured not only by the texture but also by the object behind it
Because I have a GUITexture that is located before a wall. When I click on the gui texture unity executes both the scripts (the one attached to the gui texture and the one attached to the wall). So its as if I clicked on both objects!
Both the wall and the guitexture have the function OnMouseDown
Answer by Owen-Reynolds · Mar 12, 2013 at 02:52 PM
http://forum.unity3d.com/threads/6760-Mouse-clicks-through-a-GUI has a discussion of this. It's kind of old, but don't see anything newer. To sum up: there's no great answer, since some people want clicks to go through guiTextures.
But, a hacky solution there (about 1/2-way down) is to create a plane with a trigger, childed in front of the camera where the GUI is. It will then "catch" all OnMouseDowns (won't do anything, just prevent the wall behind from getting them.)
Answer by Dealzu-The-Wikid · Jul 19, 2014 at 03:59 AM
You can put thiungs in layers and then use raycasting to ignore or only select that layer. http://docs.unity3d.com/ScriptReference/Physics.Raycast.html ...This ignores layer 10.