From 5b158af90739dcbb89c1538a6cb8c65a875dce80 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 26 Nov 2020 20:52:34 +0800 Subject: *misc --- .../StyledInspector/StyledInteractiveDrawer.cs | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledInteractiveDrawer.cs (limited to 'Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledInteractiveDrawer.cs') diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledInteractiveDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledInteractiveDrawer.cs new file mode 100644 index 00000000..1f31e352 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledInteractiveDrawer.cs @@ -0,0 +1,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; + } + } +} -- cgit v1.1-26-g67d0