#why do you need TextMeshProUGUI? TMP_

1 messages · Page 1 of 1 (latest)

glacial lily
#

If I'm reading correctly TextMeshProUGUI adds additional features to handle click events and mouse events. Such as the IPointerClickHandler. I believe this is all things that this adds to the base class of TMP_Text. So if I got rid of it I would have to write extra code for handling mouse input and keyboard input like spacebar.

At least that's what I'm understanding in the API. I could be wrong on this.

It also has Canvas Integration so it works with things like the HorizontalLayoutGroup, ContentSizeFitter, etc where as TMP_Text doesn't...

Is there any real reason not to use it over TMP_Text for a 2D UI?

I'm not trying to be argumentative, just trying to understand the best I can! Your input is appreciated.

left tundra
#

TMP_Text is the parent type to TextMeshPro and TextMeshProUGUI.

terse spindle
#

You are incorrect. TMP_Text is a superset of TextMeshProUGUI not a subset

left tundra
#

TextMeshPro is used for non-UI rendering.

#

Unless you need to configure something that is unique to TextMeshProUGUI , you can use TMP_Text to refer to both component types.

glacial lily
#

Right, and all my text is handled on the canvas, so I can use both TMP_Text and TextMeshProUGUI. And yes TMP_Text is the parent class, which is why TextMeshProUGUI adds functionality to it, not the other way around.

So I should be safe to use TMP_Text for plenty, but for certain things such as canvas integration and click events I need to use TextMeshProUGUI.

Does that sum it up?

left tundra
#

TMP_Text is not a component type. You can't attach it to something.

#

TextMeshPro and TextMeshProUGUI are the two kinds of components.

glacial lily
#

Ah

left tundra
#

It doesn't matter how you refer to these components in your code.

glacial lily
#

It clicked. Thank you.

left tundra
#

You only need to use TextMeshProUGUI in your code if you want to interact with the UI-specific methods it has

#

(I've never needed to do this before)