I'm getting into Editor Scripting in Unity and quickly get taken a back by this whole SerializedProperty thing. All i'm trying to do is make this Case Sensitive checkbox stick to the right of the inspector without all that space between the text and the box itself, leaving plenty of space for the TextField.
This is what i'm currently doing:
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.Label("Search for:", GUILayout.Width(64));
searchText = GUILayout.TextField(searchText);
EditorGUILayout.PropertyField(propCaseSensitive, GUILayout.MinWidth(0), GUILayout.ExpandWidth(false));
}
I've tried GUILayout.Width and GUILayout.MaxWidth and GUILayout.ExpandWidth(false) combined with GUILayout.MinWidth (and also just by them selves)
None of which have worked, i've been stuck trying to get this simple script to work for a bit too long for me to admit and it's driving me crazy. Please help me out, Thank you :)
I think you can do it similar to your other label.
PropertyField
has an overload taking GUIContent label
. By passing in GUIContent.none
you omit the label and can instead add your own one:
// Not sure if even needed but adjust to the width you need
EditorGUILayout.LabelField(propCaseSensitive.displayName, GUILayout.Width(64), GUILayout.ExpandWidth(false));
// Don't draw the name via the default property field layout
EditorGUILayout.PropertyField(propCaseSensitive, GUIContent.none, GUILayout.ExpandWidth(false));