I was trying to set a text field to automatically update itself whenever a slider updated. Unity (currently) does not have any methods to update text through a method, which meant I needed to put it in a script.
So I did that, I added the first UI text object I found (TextMeshPro) and tried to use GetComponent()
Some of you will already see my mistake, I should be using GetComponent<TMP_Text>() instead.
But I didn’t know that, and it took me 2 hours of furiously searching other help posts, only finding what I needed when I had the thought that maybe I needed TextMeshPro. Except I also discovered there are multiple ways to reference some object known by TextMeshPro, and so I tried every one of them until I found TMP_Text.
I am new to Unity, I make heavy use of the documentation when learning something new about the engine. If the new way to use Text is TextMeshPro, there should be ample warnings in the documentation on the legacy objects that this feature has been added, because tutorials and old help posts do not update with Unity.
Please add information about this and other features like it, because it is not reflected in the documentation, and I can’t even find TMP_Text when I search for it.
Not really my point, I was noting that documentation for every Unity package is separate to the core Unity documentation.
TMP_Text can be found in the scripting API section. And it does come up via a google search.
In any case this kind of newbie mistake isn’t unique to uGUI/TMPro. It’s something all newbies will make in one way or another. Then they learn, and don’t make this mistake again. If they don’t make it with this, it’ll be something else.
It could be in the docs but 95% of newbies would miss it anyway as 95% of newbies don’t read the docs.
The reason for this was because I was found through old Unity tutorials that the way to update text was through using this section. But there is no mention of TMP_Text or TextMeshPro which appear FIRST when you want to add text to a UI element. In order to use the component referred to by this document you need to specifically find the “Text” component under a legacy tab. Except I wanted to use TextMeshPro, because maybe I’d want some of the features it brings, and I figured it would be easy enough.
So I assumed naturally I should use something like:
GetComponent<TextMeshPro>()
Because hey that’s literally what it’s called in the inspector. And it didn’t work. So I searched, “TextMeshPro,” I actually found that document you linked. It didn’t mention TMP_Text. So, what am supposed to do?
I didn’t google TMP_Text as you said I could, because how was I supposed to know that’s what the component was called if it appears as “TextMeshPro - Text (UI)” in the inspector, and after looking up “TextMeshPro” and finding no hint of the name of its text box?
If Unity is going to hide legacy components to push you to new ones, or offer support for these new ways of displaying text or other features, I’d like a hint at least in the documentation, or at least it be searchable in the main site labeled “Unity Documentation?” I really didn’t like how I had to scramble into official document into another and not find a whiff that it had a specific unexpected name so I could write one line of code. That was my complaint.
Right so you were doing old, out of date tutorials, and looking at the documentation for old, out of date Unity versions, and it’s Unity’s fault that you were lead astray?
Maybe do some up to date tutorials and you won’t have this issue.
I’m not letting you passive-aggressively insult me instead of understanding the issue I brought up. My complaint is literally with the Unity documentation. What’s your deal?
Typically, I can do a search in the scripting API and find out what I need far faster than poring over video tutorials about the problem, or if I wanted to adjust other aspects of that specific component, it would’ve been nice to read about it as well. Do you really have so much of a problem with people wanting a warning or hint about newer systems/packages?
I mean the documentation for every official package is available throught the package manager:
It makes sense that if you are using a newer version of Unity, you are either:
A: Are reading up to date documentation
B: Or reading the documentation for the associated package
Unity’s documentation is pretty comprehensive. You just got a little lost because you’re new to Unity. Every newbie will do this in some form or another, whether it be getting UI Toolkit confused with the older systems, of not knowing of TMPros vs the old legacy UI components. Oh well, lesson learnt. Now you won’t make the same mistake.
UGUI 1.0 did NOT contain TextMeshPro. The inclusion of TextMeshPro happened in UGUI 2.0, fairly recently . You will never have old documentation containing new info which wasn’t true for the version you’re looking at. Please try to synchronize your version numbers, look at the same documentation version as the packages you’re using otherwise you will have a really bad time with any kind of software that changes often. Unity does change often.
Pardon my apparent mistake, and apparently my “ranting,” I assumed this would be a good place to post this. Searching about people complaining about Unity’s documentation reveals that people have complained about it in general . Yet they also say it is quite good, and I agree, it is good in general, and that’s why I started this.
But you sir, in particular have not been helpful. You could amend that by actually pointing to the way that one would go about “reporting the issue” to any “fellow newbies” such as myself who may or may not stumble into the forums looking for why their Text components don’t work like they expect them to.
I appreciate this actually, though I think the version of Unity I’m using doesn’t have UGUI 2.0, I don’t have an option to update it. But I opened the docs for TextMeshPro again and actually found what I was looking for, a reference to the TMPro namespace and TMP_Text! If only I knew how to navigate it before.
Don’t use Get component(), make the variable either “public” or “[SerializeField] private” and add the field in the Inspector.
This goes for all components types.