GUI textures click detection problem

Hi all… I’ve found a quirky behaviour in GUI textures; I’m using some GUI textures as interface elements to my game: you click (OnMouseUp) on each of them and everything works ok.
But if you add another GUI texture as background element, then no click is detected anymore… The buttons are inside a gameObject and the backgrounds are inside another gameObject; the two are drawn in the proper order (buttons on top of BG).
Has anyone an idea of what’s going on ?

Can you start by clarifying whether you’re using UnityGUI (GUI.Button, GUI.Label, etc.) or GUITextures? I only ask to be sure, it seems that you’re using GUITextures but it would help to have confirmation. Also, do you have a small snippet of sample code you can provide?

Definitely using GUITextures, I was thinking it was quite clear, sorry.

The GUItextures I’m using as buttons have attached a script of the kind:

function OnMouseUp (){
doMyStuff;
}

Till the buttons are by themselves, everything works perfectly; but if another GUITexture is drawn behind the buttons (with no script attached) then all buttons stop responding to clicks…

Yeah, writing “GUI textures” (two words) leaves room for interpretation, or mis-interpretation. Saying “GUITextures” (one word) makes it crystal clear. :slight_smile:

I can use your code (properly making it doMyStuff() ← with parens) and have two GUITexture items with the script attached, and a third without it that’s a backdrop, and I get clicks on the GUITextures just fine. Are you sure there’s not some other script or problem at work here that’s causing confusion? Perhaps a small sample project you can post/share?

Tip: wrap code in your posts in code tags, either use the Code button when writing a post or manually wrap it in [ code ]…[ /code ] blocks (without those spaces). :slight_smile:

Finally found the solution; the thing is that you have to set the Z transform of the different GUITextures; even though this can give no apparent graphic change, it solves the click hierarchy problem.
If you leave thing like drawn by default by Unity, things might (but also may not) look graphically correct (with things overlaying in the proper order) but interactivity won’t work.
Just bring things that are clickable closer to the screen using Z tranform and they’ll work !
Thanks to HiggyB for pointing me in the right direction, even though a bit more readable and less criptic Unity documentation sometimes would help !
That would be a much more appreciated investment than a windows version from the Unity team…

Please take a minute and log a bug (from the Help menu) about the page(s) in question to help ensure it’s on our radar. Thanks!

Windows users might disagree. :wink:

Docs are an on-going effort and we’ll continue to improve them, drop us a bug report so we can be sure to do that for these pages in particular.