For the sake of simplicity I will explain this on a simple example.
I’m having a Monobehaviour or a custom [Serializable] class that holds multiple ints:
class HoldingInts : MonoBehaviour {
public int A;
public int B;
public int C;
}
The default Inspector puts a label in front of those three properties that I can click and drag to change the number without having to type.
Now, these take a lot of space, so I want to have an Editor or PropertyDrawer that put them side by side, like the X,Y,Z components of a Vector3 for example, so I do this:
GUIStyle overflowStyle = new GUIStyle();
overflowStyle.clipping = TextClipping.Overflow;
GUILayoutOption w8 = GUILayout.Width(8);
GUILayoutOption w25 = GUILayout.Width(25);
GUILayoutOption xw = GUILayout.ExpandWidth(true);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("My Ints");
EditorGUILayout.LabelField("A", overflowStyle, w8);
EditorGUILayout.PropertyField(prop.FindPropertyRelative("A"), GUIContent.none, w25, xw);
EditorGUILayout.LabelField("B", overflowStyle, w8);
EditorGUILayout.PropertyField(prop.FindPropertyRelative("B"), GUIContent.none, w25, xw);
EditorGUILayout.LabelField("C", overflowStyle, w8);
EditorGUILayout.PropertyField(prop.FindPropertyRelative("C"), GUIContent.none, w25, xw);
EditorGUILayout.EndHorizontal();
Which gives me what I want visually, but my custom labels are not connected to the properties, so I can’t click and drag them to change the numbers.
Is it possible to connect those custom labels to the properties?