Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 929 Bytes

UNT0027.md

File metadata and controls

35 lines (26 loc) · 929 Bytes

UNT0027 Do not call PropertyDrawer.OnGUI()

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.