- Home /
Simple text GUI
Hey guys, so I'm pretty new to Unity's UI system and I have a question. So I have a bool in a script and when the bool is returned true, I want a simple text to show up in the left under corner of the screen, how can I achieve this with preferably no inspector setup at all, so everything done true scripting. It's just a simple sentence so something like this
if(bool == true)
{
GUI.enabled = true;
}
else GUI.enabled = false;
what is the most efficient way to achieve this (I don't know how to work with canvasses and stuff and all the new things in unity 5.0)
Thanks!!
Answer by CaKeMeaT · Jun 04, 2015 at 09:58 PM
If you simple need to display one thing, like FPS or a small watermark I still like the legacy OnGUI() functions
http://docs.unity3d.com/Manual/gui-Basics.html
You can place an IF statement inside of here and wrap it around everything
void OnGUI () {
if(bool == true)
{
// simple, but you could put tons of logic in here too
GUI.Label(new Rect(20,40,80,20), "Text Here, COOL! "));
}
}
Hey, thanks, I also do like the old way of doing this, you do have a little typo though, after the text 'text here, cool', there should be only one ')' :) But apart from that it works perfectly! Thanks a lot!!
Answer by kami1339 · May 31, 2019 at 08:05 AM
Ok Enough. The best way to make it manually:
1-Make an object
2-Add component>Rendering>Gui Text
You made .............!