Custom PropertyDrawer in Array. Problem with expanding.

This is a simple script that does nothing. And I had a problem with the “expanding” (in inspector) elements of the array containing it. What is wrong?


Without custom script:
123601-propertydrawer-default.gif


With custom script:
123600-propertydrawer-custom.gif


Custom PropertyDrawer code:

[CustomPropertyDrawer(typeof(Pool))]
public class PoolDrawer : PropertyDrawer
{
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.PropertyField(position, property, label, true);
    }

   
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        return EditorGUI.GetPropertyHeight(property);
    }
}

I know this answer is kind of late, but if it helps anyone:

Just change the return in the GetPropertyHeight to:

return EditorGUI.GetPropertyHeight(property, label, true);

The only change is the true boolean parameter which accounts for the child property heights in the editor GUI calculation.,This answer is kind of late but if it helps anyone:
Just change the return of the GetPropertyHeight to:

return EditorGUI.GetPropertyHeight(property, label, true);

The difference is the last true parameter that enables children to be included in the height calculation.

Actual result: The first first element of an array doesn’t expand correctly if it uses custom property drawers

Direct2HR App

How to reproduce:

  1. Open the attached project
  2. Open the “SampleScene” and select “Input array” in the Hierarchy
  3. Try to add bindings to the very first element of the array via the plus sign button
  4. Observe that the array doesn’t expand correctly

Alternatively:
3. Select the “Custom” object and change the first element’s field to “A” in the dropdown menu
4. Observe that the expansion is broken for the first array element only (might be broken for other too if checked on an older, non-fixed version)

MyAdvocateAurora Health