- Home /
GUITEXT over a GUIButton
how can i get a gui text above a gui button,i have tried several thing but the text always appear behind the button
Why do you need to display a GUIText on top of a button? Can't you just write the text on the button ins$$anonymous$$d? As in, GUI.Button(Rect BtnRect, "TextToDisplay");?
bcoz i dont want to use Unity's default GUI,and we cannot put text on a Gui.Button or GUI.label,the text will not come on the button in any case wether we use a texture2D or a GUIStyle.
Answer by Ashkan_gc · May 13, 2011 at 07:16 AM
OnGUI (all unity gui calls) are executed for the screen space and are always drawn on top of any other things on your screen. there is no consept of layers or ... for them. OnGUI don't take cameras into account and you can not render them for a camera or another, they are something general executed for the final image drawn on the screen.
hopefully the next GUI system that unity will provide will be something more flaexible and can be drawn on textures too.
Answer by Eric5h5 · May 13, 2011 at 07:04 AM
You can't, OnGUI is always on top. Better not to mix GUIText/GUITexture with OnGUI, use one or the other.
Answer by Dreamer · May 13, 2011 at 07:22 AM
You can use GUI class purely instead of using combining GUI approach:
http://unity3d.com/support/documentation/ScriptReference/GUI.html
function OnGUI () { GUI.Button (Rect (10, 10, 100, 20), "Hello Button!");
GUI.Label (Rect (10, 10, 100, 20), "Hello Text!"); }