DrawInspectorCategory.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Cristian Pop - https://boxophobic.com/
  2. using UnityEngine;
  3. using UnityEditor;
  4. using Boxophobic.Constants;
  5. namespace Boxophobic.StyledGUI
  6. {
  7. public partial class StyledGUI
  8. {
  9. public static void DrawInspectorCategory(string bannerText)
  10. {
  11. var categoryFullRect = GUILayoutUtility.GetRect(0, 0, 18, 0);
  12. var categoryBeginRect = new Rect(categoryFullRect.position.x, categoryFullRect.position.y, 10, 18);
  13. var categoryMiddleRect = new Rect(categoryFullRect.position.x + 10, categoryFullRect.position.y, categoryFullRect.xMax - 32, 18);
  14. var categoryEndRect = new Rect(categoryFullRect.xMax - 10, categoryFullRect.position.y, 10, 18);
  15. var titleRect = new Rect(categoryFullRect.position.x, categoryFullRect.position.y, categoryFullRect.width, 18);
  16. if (EditorGUIUtility.isProSkin)
  17. {
  18. GUI.color = CONSTANT.ColorDarkGray;
  19. }
  20. else
  21. {
  22. GUI.color = CONSTANT.ColorLightGray;
  23. }
  24. //Workaround for flickering images in CustomInspector with Attribute
  25. //GUIStyle styleB = new GUIStyle();
  26. //styleB.normal.background = CONSTANT.CategoryImageBegin;
  27. //EditorGUI.LabelField(categoryBeginRect, GUIContent.none, styleB);
  28. //GUIStyle styleM = new GUIStyle();
  29. //styleM.normal.background = CONSTANT.CategoryImageMiddle;
  30. //EditorGUI.LabelField(categoryMiddleRect, GUIContent.none, styleM);
  31. //GUIStyle styleE = new GUIStyle();
  32. //styleE.normal.background = CONSTANT.CategoryImageEnd;
  33. //EditorGUI.LabelField(categoryEndRect, GUIContent.none, styleE);
  34. GUI.DrawTexture(categoryBeginRect, CONSTANT.CategoryImageBegin, ScaleMode.StretchToFill, true);
  35. GUI.DrawTexture(categoryMiddleRect, CONSTANT.CategoryImageMiddle, ScaleMode.StretchToFill, true);
  36. GUI.DrawTexture(categoryEndRect, CONSTANT.CategoryImageEnd, ScaleMode.StretchToFill, true);
  37. GUI.color = Color.white;
  38. GUI.Label(titleRect, bannerText, CONSTANT.BoldTextStyle);
  39. }
  40. }
  41. }