Trying to retrieve graphical height of TextMeshProUGUI after text is displayed

I’m dynamically creating TextMeshProUGUI, sending it strings and having it ‘typewriter’ out. Im doing this several times making a new TextMeshProUGUI each time then displaying them. Like a fancy debug-log. However, the amount of text varies from string to string and so the height of the individual text block varies. In order to add a new text block underneath the previous, I need to be able to access the ‘height’ of the previous one displayed. For the life of me, I can’t get it. Pulling the Rect transform of the obj does not reflect the actual height of the text displayed. Getting ‘bounds’ from the TextMeshProUGUI returns 0,0,0.

What am I missing?

Thanks

-dis

The bounds of the text object as well as content of the textInfo only gets updated when the text object is processed / rendered.

Whenever you change properties of the text object, once per frame and just before culling the text object will be processed for update / rendering where for the vast majority of the time this is fine. However, when there are time when you need to be able to check the bounds of the text just after changing some of its properties like the text or point size, etc. you can use the ForceMeshUpdate() function to force an update of the text right away.

There should be several post on the forum as well as in the examples included with TMP. More specifically take a look at the TeleType.cs script which is used in the Old Computer Terminal example. These examples are include in the TMP Examples & Extras.