StyledInteractiveDrawer.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Cristian Pop - https://boxophobic.com/
  2. using UnityEngine;
  3. using UnityEditor;
  4. namespace Boxophobic.StyledGUI
  5. {
  6. [CustomPropertyDrawer(typeof(StyledInteractive))]
  7. public class StyledInteractiveAttributeDrawer : PropertyDrawer
  8. {
  9. StyledInteractive a;
  10. private int Value;
  11. private string Keywork;
  12. public int Type;
  13. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  14. {
  15. a = (StyledInteractive)attribute;
  16. Value = a.value;
  17. Keywork = a.keyword;
  18. Type = a.type;
  19. if (Type == 0)
  20. {
  21. if (property.intValue == Value)
  22. {
  23. GUI.enabled = true;
  24. }
  25. else
  26. {
  27. GUI.enabled = false;
  28. }
  29. }
  30. else if (Type == 1)
  31. {
  32. if (Keywork == "ON")
  33. {
  34. GUI.enabled = true;
  35. }
  36. else if (Keywork == "OFF")
  37. {
  38. GUI.enabled = false;
  39. }
  40. }
  41. }
  42. public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
  43. {
  44. return -2;
  45. }
  46. }
  47. }