EditorGUI: indent issue when drawing array propertry in nested struct

Hello everyone.

I am trying to implement a custom property drawer for a struct that wraps an array.

(Unity 2022.3.6f1)

For example:

public class PropertyTest : MonoBehaviour
{
    [Serializable]
    public struct Wrapper
    {
        public int[] value;
    }

    [CustomPropertyDrawer(typeof(Wrapper))]
    public class WrapperPropertyDrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.PropertyField(position, property.FindPropertyRelative("value"), label);
        }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            return EditorGUI.GetPropertyHeight(property.FindPropertyRelative("value"));
        }
    }

    public Wrapper wrappedArray;
    public int[] regularArray;
}

This works, but in the inspector the field has some extra indent that I want to get rid of:

This appears to be an issue with Unity 2022. In Unity 2020, the same property drawer looks correct:

1 Like

Looks like there is already a bug report for this:

1 Like