UNT0027 Do not call PropertyDrawer.OnGUI()

July 16, 2022 ยท View on GitHub

You can derive PropertyDrawer to create custom drawers. But default implementation for OnGUI(Rect position, SerializedProperty property, GUIContent label) will display no GUI implemented in the Unity inspector.

Examples of patterns that are flagged by this analyzer

using UnityEngine;
using UnityEditor;

class MyDrawer : PropertyDrawer
{
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
        base.OnGUI(position, property, label);
    }
}

Solution

Remove base.OnGUI() :

using UnityEngine;
using UnityEditor;

class MyDrawer : PropertyDrawer
{
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
        // code your own OnGUI here, do not use base.OnGUI()
    }
}

A code fix is offered for this diagnostic to automatically apply this change.