x


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.

more ▼

asked Jul 07 '10 at 06:10 PM

TinyUtopia gravatar image

TinyUtopia
270 22 26 38

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Jul 07 '10 at 06:16 PM

Mike 3 gravatar image

Mike 3
30.7k 10 67 255

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3815
x567
x430
x52

asked: Jul 07 '10 at 06:10 PM

Seen: 3480 times

Last Updated: Jul 07 '10 at 06:10 PM