Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
2
Question by KillitsGaming · May 02, 2017 at 02:18 PM · c#uitexttextfieldlinebreak

Line break UI Text field

Hi I'm trying to set the text with string can't get the line break to work. want it to look this one alt text but it looks like this all mess up alt text

     the code that i am use to set the items description

     [SerializeField]
     private Text description;
     [SerializeField]
     private string text;
 
     public void OnMouseOver()
     {
         Debug.Log("isset");
         description.text = text;
     }


1.png (174.9 kB)
2.png (174.3 kB)
Comment
Add comment · Show 1
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 KillitsGaming · May 05, 2017 at 08:51 PM 0
Share

hi, I have tried this is what I get alt text

alt text

4.png (24.6 kB)
ice-screenshot-20170505-135017.png (159.6 kB)

1 Reply

· Add your reply
  • Sort: 
avatar image
7

Answer by FM-Productions · May 02, 2017 at 06:52 PM

Hi,

you may find your answer here: http://answers.unity3d.com/questions/138464/how-to-make-a-line-break-in-a-gui-label.html

One short solution: use the character "\n" - without the double quotes - in your text variable for a line break.

Comment
Add comment · Show 2 · 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 RobAnthem · May 06, 2017 at 04:15 AM 0
Share

What @Eicher means to say is that in C#, when we want to create a string with a line break, we use "\n" for this. This can be very useful, and if you find you need to do it often, you could always do something like this.

 public string AddLine(string oldString, string newLine)
 {
     oldString += "\n" + newLine;
     return oldString;
 }

Now if you want to do this in the editor, and ensure that it comes out as a proper multi-lined string. You can choose a specific character like our codes line ending ";" and use it as a breaker. So in-Editor you can write it our like this.

 This item is an item;
 It does item-like stuff;

or

 This is another item;It is very itemlike;


Then you can do this.

      public void On$$anonymous$$ouseOver()
      {
          text.Replace(";", "\n");
          description.text = text;
      }
avatar image KillitsGaming · May 07, 2017 at 06:24 PM 0
Share

yes have tried but it is not working

alt text where I'm trying to set the item description of all item and yes all of them have the script on them. so i can change it by what item it is alt text

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.

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

How to use special symbols 1 Answer

,InputField backspace returns already send text 0 Answers

What's your equivalent of old GUIStyle ? 0 Answers

How to measure the width of a string? 0 Answers

Display fixed number of words in textbox at a time 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