- Home /
Breaking text line in GUI.Box
Hello , friends , solved the problem of directing players to a website , this script works fine , but I have another problem , I can not break the lines of text in GUI.Box because the text and shown on a single line. please help me ... what should I add to this code. Thank you very much .
This is the script I have
#pragma strict
private var displayMessage : boolean;
function OnTriggerEnter(other : Collider)
{
if(other.tag == "Player")
{ //audio.clip = Sound;
//audio.Play();
displayMessage = true;
}
}
function OnGUI()
{
if(displayMessage)
{
GUI.Box(Rect(200,100,Screen.width - 400, Screen.height - 200),"TEXT");
if(GUI.Button(Rect(Screen.width/3 - 100,Screen.height - Screen.height/2.5,200,100),"APAGAR"))
{
displayMessage = false;
}
if(GUI.Button(Rect(Screen.width/3*2 - 100,Screen.height - Screen.height/2.5,200,100),"ENVIAR RESPOSTA"))
{
Application.OpenURL("http://www.marketfidelidade.com.br");
}
}
}
Answer by robertbu · Feb 23, 2014 at 05:24 AM
The only GUI.Box you have in the code is line 20 with only the string 'TEXT'. I assume you want a much longer string broken into lines. You can break text into lines by inserting a newline character at the position of the break. For example:
GUI.Box(Rect(200,100,Screen.width - 400, Screen.height - 200),"This\n is a long\n line of text\n split into some lines");
Your answer
Follow this Question
Related Questions
Wrap text textmesh 0 Answers
Wrapping a Textmesh text 5 Answers
How to calculate a TextMesh width without rendering it ? 2 Answers
TextMesh Pro, indent line that is wrapped. 1 Answer
Adjusting the transform width to match wrapped text (TextMeshPro) 0 Answers