x


Break Line to GUI.Label

Hi, I need to break line in GUI.Label, How can I do it? I can't to use "\n" 'cause I'll take the text of DB for GUI.Label.

more ▼

asked May 17 '11 at 06:23 PM

Ricky Stefani gravatar image

Ricky Stefani
9 5 8 14

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

2 answers: sort voted first

Maybe you can do something like this:

var theStringFromDB;
var theNumberOfCharactersThatsFitsInTheLabelOnOneRow : String;
var theNumberOfCharactersThatsFitsInTheLabelOnOneRowOnRowTwo : String; 
var theLengthOfTheStringFromTheDB = theStringFromDB.Length;
var newRow;
var newRow2;

if (theLengthOfTheStringFromTheDB >= theNumberOfCharactersThatsFitsInTheLabelOnOneRow)
{
newRow = theStringFromDB.Insert(theNumberOfCharactersThatsFitsInTheLabelOnOneRow, "/n")
theStringToDisplay = newRow;

if (newRow.IndexOf("/n") >= theNumberOfCharactersThatsFitsInTheLabelOnOneRow)
{
newRow2 = newRow.Insert(theNumberOfCharactersThatsFitsInTheLabelOnOneRowOnRowTwo, "/n")
theStringToDisplay = newRow2;
}
}

Haven't tested and verified at all, but it might get you an idea.

more ▼

answered May 17 '11 at 07:40 PM

Tommy gravatar image

Tommy
156 20 22 27

Good Idea but My boss doesn't has I use the "n".

May 17 '11 at 08:15 PM Ricky Stefani
(comments are locked)
10|3000 characters needed characters left

If the GUIStyle that you use to display your label has wordWrap set, it should wrap when necessary.

more ▼

answered May 17 '11 at 08:06 PM

Molix gravatar image

Molix
4.8k 17 27 66

I'm using wordWrap, but I need to change the font size but I don't know how to do that.

May 17 '11 at 08:19 PM Ricky Stefani

Use GUIStyle for font size

May 17 '11 at 09:17 PM DaveA
(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:

x3813
x161
x129
x41

asked: May 17 '11 at 06:23 PM

Seen: 1402 times

Last Updated: May 17 '11 at 06:23 PM