- Home /
GUI Problems
How can I place my GUIButtons drawn with the OnGUI function, behind some GUI Textures in my Scene, this is very frustrating as I have my mouse set to a GUITexture as a custom cursor and it appears behind my buttons despite having a very high Z axis Value Thanks Guys
You can try lowering the GUI.depth in the OnGUI(). $$anonymous$$ake sure to store the org value so you can set the depth back to what it was previous if you need other gui to render how it was(possibly in front of other gui)
var depth=GUI.depth;
GUI.depth=0;
//All gui stuff
GUI.depth=depth;
Will this make the GUI Drop down behind other things? if so this is perfect, and can Depth be negative?
i accidently said to raise it, what i meant is lower it :P. Im not sure if it can be negative, i think 0 is the lowest it goes..you can try i guess...but im pretty sure 0 is the lowest
Thats how ive done my custom cursors as well @tomekkie2 ,indeed works well
This did not solve my problem the depth only affects other on GUI objects not in scene GUITextures
Answer by tomekkie2 · Jun 20, 2012 at 10:31 PM
Use GUI.DrawTexture for custom cursor and use it at the very end of OnGUI function, after all buttons have been drawn, and that will appears on top. You can place the texture at:
Input.mousePosition.x - Texture.width/2, Screen.height - Input.mousePosition.y - Texture.height/2