LargeHeaderDrawer.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using UnityEditor;
  2. using UnityEngine;
  3. namespace RootMotion {
  4. // Custom drawer for the LargeHeader attribute
  5. [CustomPropertyDrawer (typeof (LargeHeader))]
  6. public class LargeHeaderDrawer : DecoratorDrawer
  7. {
  8. // Used to calculate the height of the box
  9. public static Texture2D lineTex = null;
  10. private GUIStyle style;
  11. LargeHeader largeHeader { get { return ((LargeHeader) attribute); } }
  12. // Get the height of the element
  13. public override float GetHeight ()
  14. {
  15. return base.GetHeight () * 2f;
  16. }
  17. // Override the GUI drawing for this attribute
  18. public override void OnGUI (Rect pos)
  19. {
  20. // Get the color the line should be
  21. Color color = Color.white;
  22. switch (largeHeader.color.ToString().ToLower())
  23. {
  24. case "white": color = Color.white; break;
  25. case "red": color = Color.red; break;
  26. case "blue": color = Color.blue; break;
  27. case "green": color = Color.green; break;
  28. case "gray": color = Color.gray; break;
  29. case "grey": color = Color.grey; break;
  30. case "black": color = Color.black; break;
  31. }
  32. color *= 0.7f;
  33. style = new GUIStyle(GUI.skin.label);
  34. style.fontSize = 16;
  35. style.fontStyle = FontStyle.Normal;
  36. style.alignment = TextAnchor.LowerLeft;
  37. GUI.color = color;
  38. Rect labelRect = pos;
  39. //labelRect.y += 10;
  40. EditorGUI.LabelField(labelRect, largeHeader.name, style);
  41. GUI.color = Color.white;
  42. }
  43. }
  44. }