Hey all,
I am having the problem that I have drawn 2 GuiTextures in front of eatch other and now the GUITexture that is in the front is not clickable anymore because of the GUITexture behind it. So I used on of the 2 as a background and the other as a button. Is there a better way to do this where my button is clickable ? Because it only works when I disable my backgroundGUITexture.
And is there a way that I can modify the rank of being drawn first. Because I have tried to change the order of the code but that didnt changed much.
Some GUITextures come behind the backgroundGUITExture.
Greetz
Nysuatro
You should use Gui.depth Unity - Scripting API: GUI.depth
Usually the GUI you want in front has negative a number like GUI.depth = -1 while the one at the back is GUI.depth = 0. At least that worked for me. Please notice that in order to achieve this I created two different scripts using the OnGUI() function. Finally, place GUI.depth at the start of OnGUI().
C#:
void OnGUI() {
GUI.depth = -1;
…
…
}
Ok thank you for the reply. I think I still did something wrong. I put the code :
function OnGUI() { GUI.depth = -1;}
in the scriptcomponent of my GUItexture and
function OnGUI() { GUI.depth = 0;}
for the other one. But it didnt had an effect. I guess I have to use the OnGUI function on my camera?
GUITexture are not related to OnGUI
OnGUI is used on GUI / GUILayout only, thats the new UI from Unity 2.x
GUITexture / GUIText are the deprecated UI components from Unity 1.x
GUITexture as they are true 3d object, will use the information on the transform
Ow ok, thank you. Didnt knew that.
dreamora is right apologize for the mistake.
I just solved it by changing the Z-axis in the transform component. Thanks for the replyes everybody.