- Home /
C# \n won't break to a new line
I've been looking around on how to get a long string to break to a new line and I came across \n but however everything after \n doesn't display can I get some help? Thanks in advance.
void OnGUI() {
GUI.Label(new Rect(10, 10, 100, 20), "line one \n line two");
}
Answer by termway · Jul 26, 2012 at 09:08 AM
Your Rect height is too small to display all lines.
try this instead :
void OnGUI() {
GUI.Label(new Rect(10, 10, 100, 40), "line one \n line two");
}
I have big rect , but still not working...
GUI.Box(new Rect (Screen.width 0.2f , Screen.height 0.2f,500,300),"Racing 3D is exiting racing game for one \\n who like to play 3D game. This game takes input from the touch for acceleration and tilt for the left right movement");
You need to add new line separator in your text : \n
Also look at : http://forum.unity3d.com/threads/multiple-lines-of-story-in-one-gui-box.74970/
@watermy You sir are awesome. I was working with the UFO 2D tutorial and was making $$anonymous$$or edits to the "You Win!" test to add a "/nPress ESC to quit" and I was thinking the /n didn't work, but silly me, the text box was too small...
Answer by jithin-kg · Dec 01, 2018 at 01:04 PM
In the Inpector you can set the Text's Vertical Overflow property to overflow . If it is set to truncate it wont worked for me.
Your answer
Follow this Question
Related Questions
How to get the number of lines in a GUI.Label by setting a max width. 2 Answers
How to use line break for GUI.Lable 1 Answer
how to accomplish:"When click a button , four button occour ." 0 Answers
GUI.Label font size display incorrectly on iPhone 4 2 Answers
How do I create a text box to display scrollable text I send it via script? 1 Answer