Getting the render length of a text string

Hi

I’m not sure if I have missed the relevant documentation, but is there an easy way to get the size a text string will render on screen. This would enable me to perform either center the text, or check it stays within an area.

I am particularly interested in finding the length of the GUI tooltip string, to ensure it does not run offscreen.

thanks

It’s documented, but slightly obscure.

GUIStyle.CalcSize

Note that you call this on the GUIStyle object, so you need to get that out of the skin first, e.g.:

myGuiSkin.GetStyle("label").CalcSize(new GUIContent("some text"));

thanks, will get stuck into the gui style stuff