- Home /
Question by
TinyUtopia · Jul 07, 2010 at 06:10 PM ·
guitextstringformat
format text block in GUI.Box
I have a paragraph long string of text that I am placing in a GUI.Box. This string runs as one long line and does not start a new line when the text runs out of the bounds of the GUI.Box.
I would like a way to have the string automatically break and start a new line whenever a certain number of characters has been printed. Ideally, I would be able to enter the width of the GUI.Box so that the text is correctly formated to fit inside properly.
Comment
Best Answer
Answer by Mike 3 · Jul 07, 2010 at 06:16 PM
All you need to do is change the GUIStyle for box to use wordWrap
Quick example:
GUIStyle boxStyle = "box";
boxStyle.wordWrap = true;
GUI.Box(new Rect(50, 50, 100, 100), "aaa aaa aa aaa aaa aa aa aaa aa aa aa aa aa aa aa a a a aaaa aa aa aaaaa a aa aa a a a a a aaa", boxStyle);
Though generally you'll want to copy the original box style, change it, and store it as a member variable in the script