Tooltip that stretches

Hi there,

How would I go about making tooltip that stretches itself by how much text it includes? You know like (“My text”).TextHeight.

Because if I have window 50x20 and I wanna write only few words its okay.
But if I have a lot of text, like entire description it will go over hat little window.

Any ideas or I have to set with,height manually?

You should really specify if you are working with immediate mode GUI or with new UI from 4.6, but I’ll provide for both.

For immediate mode GUI:

You can use the GUIStyle.CalcHeight to calculate the height of the text content and then you can adjust your rect accordingly.

For New UI 4.6:

You can use a Text elements for your tooltip. Then for the Text component there are various options that you can use like Best fit to make sure your text always stays in the same region. Or you can check this another option: 4.6 UI Text rect does not expand automatically