- Home /
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.
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...
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));
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!
33 upvotes on the answer, 0 votes on the question. You guys realise that without a question there would be no answer, right?
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
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
Follow this Question
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