Wraping text to fit in a gui box

I need to know what code to use to make a string fit in a GUI box, when the string is longer than width of the GUI box… any ideas?

Use a custom GUI Skin and change the Box’s WordWrap parameter to true in the inspector.

Alternatively, you could create a new GUI Style on the fly and use this with changed settings, using the current GUI Skin’s Box style as a base.

Pseudocode, not tested:

GUIStyle style = GUIStyle.Box;

style.wordWrap = true;

GUI.Box(yourRect, yourText, style);