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
1
Question by Jason B · Sep 30, 2011 at 08:07 PM · inspectortextmesh

Is it possible to request a line break inside the Inspector?

I have a tooltip system and to avoid text spilling off the side of its backdrop, I need to occasionally insert line breaks. Since each object that has a tooltip has a tooltip script attached, it also has a public string where I can change what that tooltip is.

I'm using a stylistic 3D interface, so I'm using 3D text; thus there is no automatic word wrap or anything of the sort.

I tried inserting the standard \n for a line break but it appears that this doesn't work for text entered in the inspector. Does this mean I'm going to have to write an entire script just to implement line breaks? Seems a bit convoluted, so I figured I'd ask around for alternatives.

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

6 Replies

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

Answer by Jason B · Oct 13, 2011 at 06:40 PM

Guess I'll just answer my own question since I figured out a workaround. Not a very convenient one, though. Looks like you have to type your line breaks out in Notepad and copy/paste them into the inspector. Only way to get it to work.

Hopefully the Unity team looks into this.

Comment
Add comment · Show 1 · 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 Rod-Green · Nov 11, 2011 at 01:53 AM 0
Share

Yeah, this is an issue with windows build of unity. However on $$anonymous$$ac it is possible with the 'alt/option'-enter to do a new line

avatar image
2

Answer by Eric5h5 · Sep 30, 2011 at 08:23 PM

Type alt/option-return.

Comment
Add comment · Show 1 · 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 Jason B · Oct 13, 2011 at 06:35 PM 0
Share

Doesn't seem to work. Holding alt toggles the camera mode in the scene view, and pressing enter while holding it causes Windows to make its little "oops, can't do that" sound effect.

avatar image
2

Answer by muzboz · Jan 19, 2019 at 02:55 AM

I found a good solution at this thread: https://answers.unity.com/questions/1299564/how-to-create-new-line-in-string-from-inspector.html

Add the TextAreaAttribute to your string variable, and the Inspector will now provide you with a larger text entry box that allows you to just use the Enter key to make carriage returns. Yay!

eg:

[TextArea]

public string myString;

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
avatar image
1

Answer by jahroy · Nov 11, 2011 at 02:03 AM

You can also use an escape sequence in the Inspector and replace it in your script.

We use three under-scores to represent a newline.

When you display the string to the screen you use this:

Debug.Log(someString.Replace("___", "\n"));

Sorry this came a little late...

Comment
Add comment · Show 5 · 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 Rod-Green · Nov 11, 2011 at 02:07 AM 0
Share

Hey good idea! :D

avatar image Jason B · Nov 11, 2011 at 02:25 AM 0
Share

It's not a bad idea, I don't $$anonymous$$d if it's late. I was thinking about doing this anyways because our current tooltip system needs to be rewritten a little bit to where I'm going to have to acknowledge line breaks anyways in the script. :)

avatar image jahroy · Nov 11, 2011 at 02:28 AM 0
Share

I'm sure you're aware of this, but I'll throw it out there anyways...

GUIStyle has a wordWrap property:

http://unity3d.com/support/documentation/ScriptReference/GUIStyle-wordWrap.html

avatar image Jason B · Nov 11, 2011 at 03:13 AM 0
Share

I stated in the question, I'm not using GUIs. I'm using an assortment of textured planes with 3D Texts (I find the overall effect much more pleasant and speedy than the GUI system built into Unity).

avatar image jahroy · Nov 11, 2011 at 04:17 AM 0
Share

Right on.

I was adding that more for the next guy who stumbles onto this fabulous question...

avatar image
0

Answer by jackpile · Nov 21, 2011 at 07:42 AM

Simple. On the Mac it's Option-Shift-Return.

Comment
Add comment · Show 1 · 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 Eric5h5 · Nov 21, 2011 at 07:49 AM 0
Share

Just Option-Return, no shift.

  • 1
  • 2
  • ›

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

9 People are following this question.

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

Related Questions

Line Break Within Inspector GUIText 0 Answers

Making newline ( \n ) in inspector 11 Answers

How to extend TextMeshProUgui to show new public in the inspector 0 Answers

How do I create a JavaScript class that creates an object with viewable variables in the inspector? 3 Answers

Why is my class hidden in inspector with C# and not JS? 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