Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Help Wanted How to get spacing between inspector property labels and fields?

Discussion in 'Immediate Mode GUI (IMGUI)' started by JasonC_, Jun 14, 2021.

  1. JasonC_

    JasonC_

    Joined:
    Oct 27, 2019
    Posts:
    43
    2020.3.11f1

    From a PropertyDrawer, how do I get the horizontal spacing between property labels and fields in the inspector?

    upload_2021-6-13_20-32-40.png

    The controls in the above image were drawn with:

    Code (CSharp):
    1. public override void OnGUI (Rect pos, SerializedProperty property, GUIContent label) {
    2.     EditorGUI.BeginProperty(pos, label, property);
    3.     EditorGUI.DrawRect(new Rect(pos.x, pos.y, EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight), Color.blue);
    4.     EditorGUI.TextField(pos, new GUIContent(" "), "");
    5.     EditorGUI.EndProperty();
    6. }
    Thanks.
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,613
    What exactly do you mean by get spacing? And why do you need that? Just curious.

    Do you mean GUIStyle.margin or padding perhaps?
     
unityunity