• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by TakMarche · Jul 26, 2012 at 09:00 AM · gui.labellinebreak

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 everyt$$anonymous$$ng 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");
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by termway · Jul 26, 2012 at 09:08 AM

Your Rect height is too small to display all lines.

try t$$anonymous$$s instead :

 void OnGUI() {
    GUI.Label(new Rect(10, 10, 100, 40), "line one \n line two");
 }
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vipul-Dudharejiya · Dec 11, 2014 at 10:29 AM 0
Share

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");

avatar image termway · Dec 11, 2014 at 10:43 AM 0
Share

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/

avatar image toddreser · Oct 17, 2017 at 06:40 PM 0
Share

@watermy You sir are awesome. I was working with the UFO 2D tutorial and was making minor 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...

avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Creating a Space to Type a Name 1 Answer

How to scroll label view 0 Answers

GUI.Label not displaying within GUI.BeginScrollView when GUI.Button is pressed what am I doing wrong? 0 Answers

Label Being Squished 0 Answers

GUI.Label is not showing all content 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges