- Home /
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.
Answer by karl_ · Sep 19, 2011 at 07:51 PM
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();
Answer by ruddonomy · Jun 13, 2014 at 09:29 PM
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;
Answer by RewindGameStudio · Feb 22, 2014 at 09:20 PM
I believe the more correct way is now like this: LookLikeControls
EditorGUIUtility.LookLikeControls(300,50);
This takes a label width and field width.
Answer by CaJerry87 · Dec 20, 2016 at 07:45 AM
Check out the Inspector Layout Solution: It has images that show how one can lay things out in an inspector.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Preview Window in Editor 2 Answers
Resizing an array of gameObjects 2 Answers
How to make an GUILayout.Window draggable ? 3 Answers
How to edit a enumerator in the editor? 2 Answers