EditorGui.PropertyField, how do I reduce the label's width ?
I'm learning how to make custom PropertyDrawers for a custom struct, it has three properties named r, g, b.
The following code...
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label){
position = EditorGUI.PrefixLabel(position, label);
EditorGUI.PropertyField (position, property.FindPropertyRelative ("b"));
}
...lets me display the property B in this manner :
I'm trying to cut the width of this property by 3 so I can put 3 floats in a row similar to how Vector3 are displayed.
I figured how to place multiple float field in a single row in a way that looks good, but it only works well If I remove the labels with GUIContent.none, else the labels always sticks with this absurdely huge width you can see above, and I couldn't find any way of altering it.
How do I reduce the width of the "B" label when using EditorGui.PropertyField ?
Answer by Adam-Mechtley · May 04, 2017 at 06:30 PM
Does it work for you to temporarily change the value of EditorGUIUtility.labelWidth?
Yes, that's definitely the feature I was looking for, got it working like a charm. Thank you! Just to make sure, should I manually restore the original value after the job is done, like with EditorGUI.indentLevel ?