1
\$\begingroup\$

I was following a tutorial on how to create a dialogue Box in Unity, and in one part of the tutorial the tutor imports UnityEngine.UI and creates an object of type Text, but my version of Unity is 2019.3.5f1 and I learned through searching a bit online that this UnityEngine.UI doesn't exist anymore in this version, and that it was replaced with UnityEngine.UIElements, and this Text type doesn't exist anymore as well.

I couldn't find a replacement for Text or what is the new nomenclature, nothing from trying stuff that popped in the auto complete or searching for answers in the Internet gave me answers. Maybe I just searched poorly, but if anyone happens to know, could you kindly answer?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Try Adding "TextMeshPro". It ships as part of Unity... Window -> TextMeshPro -> Import Essentials. You'll then have a control of type TextMeshProUGUI (in code) which has a .Text property and all the other things you'd expect, as well as very decent font support. You'll also be able to add components of type "TextMeshPro" to your UI elements if you prefer Drag+Drop to coding \$\endgroup\$
    – Basic
    Commented Oct 27, 2020 at 8:16

1 Answer 1

2
\$\begingroup\$

It's still the same.

UnityEngine.UI didn't go away, it's just considered a package now, so its documentation has moved out of the core and into its own sub-page.

Open your Package Manager window, and install/update the Unity UI package if it's not installed or out of date.

Unity UI in the Package Manager

Now adding using UnityEngine.UI; at the top of your script will let you access the Text type just like in the tutorial.

(Though for many purposes you'd likely prefer the TMPro.TextMeshProUGUI type, which does the same thing but with signed distance field rendering that tends to look more crisp, and offers more powerful styling options. Add the TextMeshPro package to use this one.)

\$\endgroup\$
2
  • \$\begingroup\$ Thank you! Unity is fine now with the Text, it's working but the vs code is still reporting error, it's not recognizing the UI, is there a way for me to make vs code recognize it? So it stops giving me false errors. I tried using the Assembly file and creating a reference for the UI because I heard of this but I can't find the dll. \$\endgroup\$
    – Carolina M
    Commented Oct 27, 2020 at 10:36
  • \$\begingroup\$ I know struggling with intillisense in VS Code is a common problem, but I don't use it myself so I don't have any leads for you. Try checking other answers here on the topic. \$\endgroup\$
    – DMGregory
    Commented Oct 27, 2020 at 11:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .