x


Space for describing text in EditorGUILayout too short

Hi!

I just came across the following issue.

int integerExample = EditorGUILayout.IntField("This is a longer text describing what should be filled in", integerExample );

The text "This is a longer text describing what should be filled in" gets cut. So it does not display the whole sentence. Probably a very easy thing to do, but I cannot seem to find a solution. I checked here: http://unity3d.com/support/documentation/ScriptReference/GUILayout.html but I am missing "TextWidth" or something like that. Does anyone know how to extend the space which can be used for the text in front of the input field? Thanks in advance!

more ▼

asked Nov 01 '11 at 05:05 PM

softrare gravatar image

softrare
432 7 10 15

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

There are several ways of adding help text to an editor GUI.

The 'standard' way of providing help text is to use tooltips:

GUIContent myLabel = new GUIContent("MyShortLabel", "My longer help text");
integerExample = EditorGUILayout.IntField(myLabel, integerExample);

EditorGUIUtility.LookLikeControls() can be used to make small adjustments to label width. (A bit of a hack.)

For longer descriptions you can add a help text box somewhere in the GUI. The following custom style can be used with GUILayout.Label().

// A decent style.  Light grey text inside a border.
helpStyle = new GUIStyle(GUI.skin.box);
helpStyle.wordWrap = true;
helpStyle.alignment = TextAnchor.UpperLeft;

Color c = Color.white;
c.a = 0.75f;
helpStyle.normal.textColor = c;

// Don't use EditorGUILayout.Label()
GUILayout.Label(
    "My extra long multi-line help text."
    , helpStyle
    , GUILayout.ExpandWidth(true));
more ▼

answered Nov 01 '11 at 07:29 PM

SteveFSP gravatar image

SteveFSP
1k 8 13 29

+1, Thank you so much, 3 awesome suggestions!

Nov 02 '11 at 10:17 AM softrare

wish i had the rep to up-thumb, great answer!

Mar 23 at 07:41 PM Darkhydro
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3816
x1732
x48
x37

asked: Nov 01 '11 at 05:05 PM

Seen: 1439 times

Last Updated: Mar 23 at 07:41 PM