custom inspector label width?

When I make a custom inspector like this:

target.editvariable = EditorGUILayout.FloatField("Recieve Shadows", target.editvariable);

My text is cut and reads Receive shadow with the w only half visible.
While the float field is way to big.
How van i have a bigger label?

When using

target.editvariable = EditorGUILayout.FloatField("Thickness", target.editvariable, GUILayout.Width(45));

It changes the float field, but the label its width stays the same.

4 Answers

4

The more correct way for this now is EditorGUIUtility.labelWidth. LookLikeControls is deprecated.

EditorGUIUtility.labelWidth = 250;

I just wanted to say, these have been working well for me, thanks! EditorGUIUtility.labelWidth = 30; EditorGUIUtility.fieldWidth = 20;

The way I’ve dealt with this in the past is to either use EditorGUI.Prefix() or a combination of GUILabel and an empty text field in my floatfield.

Ex-

GUILayout.BeginHorizontal();
    GUILayout.Label("Long descriptor goes here");
    EditorGUILayout.FloatField("", x, GUILayout.MaxWidth(64));
GUILayout.EndHorizontal();

I believe the more correct way is now like this:
LookLikeControls

EditorGUIUtility.LookLikeControls(300,50);

This takes a label width and field width.

Check out the Inspector Layout Solution: It has images that show how one can lay things out in an inspector.

http://answers.unity3d.com/answers/1288008/view.html