How to make this turn into multiple lines - Javascript

Hey I’m currently trying to figure out how to make this code turn into multiple lines once it gets to a certain point on the Mobile Phone Android screen so it doesn’t go off the screen it just starts a new line im using JavaScript this is my code.

#pragma strict

var Chatbox: GUIStyle;
var ChatboxText: String;

function Start () {

}

function Update () {

}

function OnGUI () {
PlayerPrefs.SetString("Chat Box ID", "Im trying to make this turn into 2 lines grr help me!!!!!! pwease");

GUI.Label (new Rect (Screen.width/8.00f,Screen.height/1.15f, Screen.width/1.50,Screen.height/10.2f),PlayerPrefs.GetString("Chat Box ID"), ChatboxText);

}

Sorry if my question doesn’t make much sense im not good at explaining things :frowning:

I’d suggest checking for the string’s length.
If it is above a certain number of letters, replace one of the spaces with \n, or so.
Did not try it, but I think that’s the general idea.

There is also a nice answer here, for long text (with scroll)

Hmmm the \n didn’t work :frowning:

Perhaps \r\n?

Is this code your doing through C+? cause in the middle of the PlayerPrefs typing /r/n just puts it in the text line on the screen

Ah, that was not my intention.
I meant during run time, before printing the text, have the code check the length of the text, and if it’s bigger than what’s meant to be on the screen, have the code replace a space (preferably after a ‘,’ or ‘.’) with “\r\n” which should act like a new line.

I still don’t get what you mean

Sorry im not understanding this very well

Just set wordWrap to true in the style

No need to apologize, I am not so good at explaining myself…

Also, hpJohn, thanks! I am not too experienced with Unity itself and all of its functions. I was actually searching for text/string functions, haha

Ahh That worked Thankyou for that now I can move on