DrawWindowCategory.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 DrawWindowCategory(string bannerText)
  10. {
  11. var position = GUILayoutUtility.GetRect(0, 0, 36, 0);
  12. var categoryFullRect = new Rect(position.position.x, position.position.y + 10, position.width, position.height);
  13. var categoryBeginRect = new Rect(categoryFullRect.position.x, categoryFullRect.position.y, 10, 18);
  14. var categoryMiddleRect = new Rect(categoryFullRect.position.x + 10, categoryFullRect.position.y, categoryFullRect.xMax - 41, 18);
  15. var categoryEndRect = new Rect(categoryFullRect.xMax - 13, categoryFullRect.position.y, 10, 18);
  16. var titleRect = new Rect(categoryFullRect.position.x, categoryFullRect.position.y, categoryFullRect.width, 18);
  17. if (EditorGUIUtility.isProSkin)
  18. {
  19. GUI.color = CONSTANT.ColorDarkGray;
  20. }
  21. else
  22. {
  23. GUI.color = CONSTANT.ColorLightGray;
  24. }
  25. //Workaround for flickering images in CustomInspector with Attribute
  26. //GUIStyle styleB = new GUIStyle();
  27. //styleB.normal.background = CONSTANT.CategoryImageBegin;
  28. //EditorGUI.LabelField(categoryBeginRect, GUIContent.none, styleB);
  29. //GUIStyle styleM = new GUIStyle();
  30. //styleM.normal.background = CONSTANT.CategoryImageMiddle;
  31. //EditorGUI.LabelField(categoryMiddleRect, GUIContent.none, styleM);
  32. //GUIStyle styleE = new GUIStyle();
  33. //styleE.normal.background = CONSTANT.CategoryImageEnd;
  34. //EditorGUI.LabelField(categoryEndRect, GUIContent.none, styleE);
  35. GUI.DrawTexture(categoryBeginRect, CONSTANT.CategoryImageBegin, ScaleMode.StretchToFill, true);
  36. GUI.DrawTexture(categoryMiddleRect, CONSTANT.CategoryImageMiddle, ScaleMode.StretchToFill, true);
  37. GUI.DrawTexture(categoryEndRect, CONSTANT.CategoryImageEnd, ScaleMode.StretchToFill, true);
  38. GUI.color = Color.white;
  39. GUI.Label(titleRect, bannerText, CONSTANT.BoldTextStyle);
  40. }
  41. }
  42. }