- Home /
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?
The UI Text class has built in Vertical and Horizontal Overflow properties:
If you're using New Unity 5 then it's easier to now drag and drop the box and set the overflow properties to false.
Answer by Cherno · Mar 16, 2015 at 04:07 PM
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);
Your answer
Follow this Question
Related Questions
Can't destroy an ui element 2 Answers
Distribute terrain in zones 3 Answers
Hi! How do I make a text that changes with the behind picture? 0 Answers
Change colour of GUI box, keep round corners. 0 Answers
Multiple Cars not working 1 Answer