Get 3D Text size

AFAIK, there is no direct access to the world size of a Text Mesh as it is possible in a regular Mesh through the "bounds" object. It is not possible to compute it from vertices data neither as there is also, no access to mesh data.

Is there already something that I am missing?

I need this for 3D HUD resizing according to content. For the moment I use the GUIstyle.CalcSize to get the text size in pixels, then use a magic scale factor to get the text world size. But this factor seems to depend on the font and also font size. Get the bounds of the TextMesh would be infinitely more simple.

Any help (hack) would be greatly appreciated! Thanks!

Hey, I know it's a bit late but I spent ages trying to figure this out too.

Eventually a found a way which while pretty hacky is the most elegant way I've found so far.

The Renderer component has a Bounds variable used for visibility culling which basically equates to a bounding box of the contents. You can use this to get the size of the TextMesh from the Renderer attached to the same object.

Here's some sample code of using it for raycasting:

public void MouseOver()
    Bounds bounds = renderer.bounds;
    Ray ray = camera.ScreenPointToRay(Input.mousePosition);
    return bounds.IntersectRay(ray);

You can get the size of the text from the Bounds.size variable.