- Home /
GUI and UI compatibility
I am making a game and I have a coin count text. It is using a GUI text because in MonoDevelop, I am not able to make a UIText. When I try to make the public UIText, there is only and option for GUIText. Is it not called a UIText, or does my MonoDevelop have a bug?
I want to put a UI image as a child of my CoinCount Text but I can't because the GUI can't be in the Canvas and the UI can't be under a GUI object.
If I add using UnityEngine.UI;
, will that fix the problem and allow me to use UIText?
There is no such thing as UIText, its Text
only, unless you are using NGUI which uses the 'UI' prefix for its widget classes.
Answer by troien · May 18, 2016 at 08:46 AM
Unless you are using some plugin from the assetstore, there is no class called UIText :p
There is the legacy GUIText, UnityEngine.UI.Text (probably the one you want) and then there is the legacy GUI/GUILayout.Label.
If you add using UnityEngine.UI;
add the top, you can use something like public Text text;
to reference your text field in a script, simply drag your gameobject with a Text component to this field in the inspector and change the text by saying text.text = "yourtextgoeshere";
somewhere in your code (in Update() for example).
If you don't add using UnityEngine.UI;
then public UnityEngine.UI.Text text;
would do the same thing.
If you are having trouble using them. You could look at the Tutorial section, specifically the section about UI.
Your answer
Follow this Question
Related Questions
UnityEngine.UI.dll 0 Answers
Check current letter in typewriter textbox? 0 Answers
How do I reference a UI text in Unity 5? (JS) 2 Answers
Changing GUI Button Script 4 Answers
ArgumentException: control 1s position in group with only 1 control 0 Answers