summaryrefslogtreecommitdiff
path: root/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledInteractiveDrawer.cs
blob: 1f31e352137b006f26f4d2440769bca5cc5b4bb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Cristian Pop - https://boxophobic.com/

using UnityEngine;
using UnityEditor;

namespace Boxophobic.StyledGUI
{
    [CustomPropertyDrawer(typeof(StyledInteractive))]
    public class StyledInteractiveAttributeDrawer : PropertyDrawer
    {
        StyledInteractive a;

        private int Value;
        private string Keywork;
        public int Type;

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            a = (StyledInteractive)attribute;

            Value = a.value;
            Keywork = a.keyword;
            Type = a.type;

            if (Type == 0)
            {
                if (property.intValue == Value)
                {
                    GUI.enabled = true;
                }
                else
                {
                    GUI.enabled = false;
                }
            }
            else if (Type == 1)
            {
                if (Keywork == "ON")
                {
                    GUI.enabled = true;
                }
                else if (Keywork == "OFF")
                {
                    GUI.enabled = false;
                }
            }

        }

        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            return -2;
        }
    }
}