Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
24
Question by spacepilot · Dec 28, 2011 at 09:30 PM · guieditorlabelstylebold

How to get a bold Labelfield (EditorGUIStyle)

How do I get a Labelfield showing bold letters? I tried using a modified style, but the Labelfield doesn't accept the new style as an option:

 EditorGUILayout.LabelField("", "Headline:", GUILayout.MinHeight(20),GUILayout.MaxWidth(320),boldtext);

the variable boldtext gets rejected. I defined it this way:

 var boldtext = new GUIStyle (GUI.skin.label);
 boldtext.fontStyle = FontStyle.Bold;

Am I using the style in a wrong way? Is there another to apply it? Somebody please help.

Comment
Add comment · Show 2
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 spacepilot · Dec 29, 2011 at 07:32 AM 1
Share

wow, so many answers...is it possible there indeed is no way? Unlike other gui-layout-elements (e.g. popup or foldout) labelfield only seems to accept guilayout-options and no styles - according to the documentation. Is there maybe a way to change the style of the guilayout-class? Switching for the moment of labelfield-usage would at least be possible then...

avatar image Bunny83 · Nov 30, 2016 at 03:57 AM 1
Share

Since the question is already bumped. The reason why this doesn't work:

 EditorGUILayout.LabelField("", "Headline:", GUILayout.$$anonymous$$inHeight(20), GUILayout.$$anonymous$$axWidth(320), boldtext);

is that the GUIStyle parameter comes before the GUILayoutOptions. So it should be:

 EditorGUILayout.LabelField("", "Headline:", boldtext, GUILayout.$$anonymous$$inHeight(20), GUILayout.$$anonymous$$axWidth(320));

2 Replies

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

Answer by Alexphauge · Jul 16, 2012 at 02:49 PM

Hello there.

I use this:

EditorGUILayout.LabelField("Inspector", EditorStyles.boldLabel);

To get the desired result. Sorry if you already solved it, but well. :)

Good luck!

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 Bunny83 · Nov 30, 2016 at 03:53 AM 1
Share

33 upvotes on the answer, 0 votes on the question. You guys realise that without a question there would be no answer, right?

avatar image JeromeJ Bunny83 · Mar 09, 2018 at 01:36 PM 0
Share

We should all move to StackOverflow.

avatar image
1

Answer by kalamtech · Mar 06, 2019 at 06:00 PM

In some cases you may want to change only a specific word or sentence, so you just need to make your text like that:

 sb.Append("<size=10> <color=yellow><b>WARNING: </b></color> Some text here</size>");

In this case my style font size is 8, so this text will be a bit bigger then the other lines, the word WARNING will be written in yellow and bold and 'Some text here' is the default color.

For more details check: https://docs.unity3d.com/Manual/StyledText.html

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 _slash_ · Dec 18, 2020 at 01:34 PM 0
Share

For this to work in editor you need to enable rich text:

 GUIStyle style = new GUIStyle ();
 style.richText = true;
 
 EditorGUILayout.LabelField("<b>Warning:</b> Stay alert.",style);

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

18 People are following this question.

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

Related Questions

How to get a italic Labelfield (EditorGUIStyle) 0 Answers

Change Text Size and height EditorGuiLayout.Popup 1 Answer

Unity Preferences' Large Heading Font 2 Answers

Animator Window Layout Problem 0 Answers

EditorGUI elements require minimum size of 24px? 0 Answers


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