How to set EditorGUILayout.PropertyField label column width?

In one of my custom inspectors, I’m iterating over each visible SerializedProperty of an object and using EditorGUILayout.PropertyField to display them in the UI for tweaking, just like a regular inspector would.

This part works fine, but I can’t figure out how to override/set the size of the label column. Right now it’s eating up way too much space and the value column fields end up very small as a consequence. Using GUILayout.Width() in the PropertyField() call doesn’t work as this affects the whole field row, not just the label part.

Does anyone know a way to do this?

Jamora gave me an idea, so I’ll answer my own question :slight_smile:
In the PropertyField doc, it’s written you can skip the property label by specifying GUIContent.none, which then allows me to specify my own label and control its size instead:

GUILayout.BeginHorizontal();
GUILayout.Label( prop.name, GUILayout.Width( 75 ) );
GUILayout.FlexibleSpace();
EditorGUILayout.PropertyField( prop, GUIContent.none, true, GUILayout.MinWidth( 100 ) );
GUILayout.EndHorizontal();

This may not have been available when this was originally posted, but a better answer now is probably to use EditorGUIUtility.labelWidth like so:

EditorGUIUtility.labelWidth = 45.0f; // Replace this with any width
EditorGUILayout.PropertyField( someProperty, new GUIContent("Label Text") );

I believe this should solve the problem that @Douvantzis was having.