StyledCategoryDrawer.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Cristian Pop - https://boxophobic.com/
  2. using UnityEngine;
  3. using UnityEditor;
  4. using System;
  5. namespace Boxophobic.StyledGUI
  6. {
  7. public class StyledCategoryDrawer : MaterialPropertyDrawer
  8. {
  9. public string category;
  10. public float top;
  11. public float down;
  12. public StyledCategoryDrawer(string category)
  13. {
  14. this.category = category;
  15. this.top = 10;
  16. this.down = 10;
  17. }
  18. public StyledCategoryDrawer(string category, float top, float down)
  19. {
  20. this.category = category;
  21. this.top = top;
  22. this.down = down;
  23. }
  24. public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materiaEditor)
  25. {
  26. if (prop.floatValue < 0)
  27. {
  28. GUI.enabled = true;
  29. EditorGUI.indentLevel = 0;
  30. }
  31. else
  32. {
  33. GUI.enabled = true;
  34. EditorGUI.indentLevel = 0;
  35. GUILayout.Space(top);
  36. StyledGUI.DrawInspectorCategory(category);
  37. GUILayout.Space(down);
  38. }
  39. }
  40. public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
  41. {
  42. return -2;
  43. }
  44. }
  45. }