5#pragma warning disable IDE0130
7#pragma warning restore IDE0130
9 [CustomPropertyDrawer(typeof(ShowIfAttribute))]
10 internal sealed class ShowIfDrawer : PropertyDrawer
12 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
14 if (!ShouldShow(property))
17 if (ConditionalMemberEvaluator.TryGetBuiltInDrawer(property, fieldInfo, out var builtInDrawer))
19 ConditionalMemberEvaluator.DrawBuiltInDrawer(builtInDrawer, position, property, label);
23 EditorGUI.PropertyField(position, property, label,
true);
26 public override float GetPropertyHeight(SerializedProperty property, GUIContent label) =>
29 : ConditionalMemberEvaluator.TryGetBuiltInDrawer(property, fieldInfo, out var builtInDrawer)
30 ? ConditionalMemberEvaluator.GetBuiltInDrawerHeight(builtInDrawer, property, label)
31 : EditorGUI.GetPropertyHeight(property, label,
true);
33 private bool ShouldShow(SerializedProperty property) =>
34 attribute is not ShowIfAttribute showIf ||
property ==
null ||
35 ConditionalMemberEvaluator.ShouldShow(property, showIf);