UI.Text
で、実際にテキストを表示した際のサイズが知りたい場合はpreferredWidth
やpreferredHeight
を使って調べることができるそうです。使い方
Text text;
float width = text.preferredWidth;
float height = text.preferredHeight;
テキストの長さに合わせてUIを調整したい場合に便利かなと思います。
リンク
Unity - Scripting API: ILayoutElement
https://docs.unity3d.com/ScriptReference/UI.ILayoutElement.html