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
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)
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.