Why doesn't the TextMeshPro textBounds get updated between frames in Play Mode Unit tests?

Hello,

I have a need to change the text of a text mesh pro UI text object and retrieve its textBounds to resize an object for a unit test. I have included Unity.TextMeshPro in the .asmdef file. I have tried multiple things like waiting for multiple frames, calling ForceMeshUpdate(), and even calling Canvas.ForceUpdateCanvases(), but the returned textBounds is always Center: (0.00, 0.00, 0.00), Extents: (-2147484000.00, -2147484000.00, 0.00). However, the text itself shows that it has changed to the correct string.

While doing the same thing in regular play mode, I just have to wait a frame after changing the text to get the correct textBounds. Is there something I’m missing to make this work in a Unity Play Mode Unit Test?

The source code should reveal this. Check out the source code over in the Packages directory to see if there are other ways of accessing the bounds recalc. I assume they just made it lazy so they don’t waste time changing bounds many times per frame, such as if several scripts all update a field.

ALSO… is this really providing you value to write a test around???

Thanks @Kurt-Dekker .