I'm using Unity 2017.2.0f3 and when I use GUIText
, it is showing "this component is part of the legacy UI system and will be removed in a future release." So what is the best alternative I should use?
Asked
Active
Viewed 2.7k times
22

Programmer
- 121,791
- 22
- 236
- 328

Atiq Baqi
- 612
- 1
- 7
- 16
-
This is unfortunate. I use GUIText for debug output and Canvas is overkill. – Xonatron Dec 02 '19 at 18:07
2 Answers
23
The Text
component replaced it. It's part of the new UI system called uGUI.
Go to GameObject ---> UI ---> Text and Unity will create a Canvas with a GameObject as a child. That child GameObject will have a Text
component. You can learn more about the new UI system here.
Example of how to modify it from code:
public Text myText;
void Start()
{
myText.text = "This is my text";
}

Programmer
- 121,791
- 22
- 236
- 328
-
6Just a note for using the new UI Framework in code. Text (or any other new UI Element) is part of UnityEngine.UI. You will have to add a using statement or use UnityEngine.UI.Text, as Unity does not automatically add it for you. – Superwayne Nov 23 '17 at 11:23
-
1Yes, that's true. Although with Visual Studio, that's an easy fix as it will give you suggestion on what to import. – Programmer Nov 23 '17 at 11:30
0
It is now replaced with the TextElement
class in UnityEngine.UIElements
http://docs.unity3d.com/2021.2/Documentation/ScriptReference/UIElements.TextElement.html

ntrch
- 76
- 1
- 22