Space Ad Mobile 9.5.1
Space Ad Mobile makes ads easy to add into your mobile game: one unified workflow for LevelPlay, AdMob, Yandex.Ads across banners, interstitials and rewarded.
Loading...
Searching...
No Matches
ShowIfDrawer.cs
1#if UNITY_EDITOR
2using UnityEditor;
3using UnityEngine;
4
5#pragma warning disable IDE0130
6namespace SCG.Editor
7#pragma warning restore IDE0130
8{
9 [CustomPropertyDrawer(typeof(ShowIfAttribute))]
10 internal sealed class ShowIfDrawer : PropertyDrawer
11 {
12 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
13 {
14 if (!ShouldShow(property))
15 return;
16
17 if (ConditionalMemberEvaluator.TryGetBuiltInDrawer(property, fieldInfo, out var builtInDrawer))
18 {
19 ConditionalMemberEvaluator.DrawBuiltInDrawer(builtInDrawer, position, property, label);
20 return;
21 }
22
23 EditorGUI.PropertyField(position, property, label, true);
24 }
25
26 public override float GetPropertyHeight(SerializedProperty property, GUIContent label) =>
27 !ShouldShow(property)
28 ? 0f
29 : ConditionalMemberEvaluator.TryGetBuiltInDrawer(property, fieldInfo, out var builtInDrawer)
30 ? ConditionalMemberEvaluator.GetBuiltInDrawerHeight(builtInDrawer, property, label)
31 : EditorGUI.GetPropertyHeight(property, label, true);
32
33 private bool ShouldShow(SerializedProperty property) =>
34 attribute is not ShowIfAttribute showIf || property == null ||
35 ConditionalMemberEvaluator.ShouldShow(property, showIf);
36 }
37}
38#endif