- Home /
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!
Answer by SteveFSP · Nov 01, 2011 at 07:29 PM
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));