설명 없음
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DrawTreeViewEmptyState.cs 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using UnityEngine;
  2. namespace Unity.PlasticSCM.Editor.UI.Tree
  3. {
  4. internal static class DrawTreeViewEmptyState
  5. {
  6. internal static void For(
  7. Rect rect,
  8. string text)
  9. {
  10. GUIContent content = new GUIContent(text);
  11. Vector2 contentSize = GetContentSize(content);
  12. GUI.BeginGroup(rect);
  13. DrawLabel(
  14. content,
  15. contentSize,
  16. (rect.width - contentSize.x) / 2,
  17. rect.height / 2);
  18. GUI.EndGroup();
  19. }
  20. internal static void For(
  21. Rect rect,
  22. string text,
  23. Texture2D icon)
  24. {
  25. GUIContent content = new GUIContent(text);
  26. Vector2 contentSize = GetContentSize(content);
  27. GUI.BeginGroup(rect);
  28. DrawLabelWithIcon(
  29. content,
  30. contentSize,
  31. (rect.width - contentSize.x) / 2,
  32. rect.height / 2,
  33. icon);
  34. GUI.EndGroup();
  35. }
  36. static void DrawLabel(
  37. GUIContent content,
  38. Vector2 contentSize,
  39. float offsetX,
  40. float offsetY)
  41. {
  42. GUI.Label(
  43. new Rect(offsetX, offsetY, contentSize.x, contentSize.y),
  44. content,
  45. UnityStyles.Tree.StatusLabel);
  46. }
  47. static void DrawLabelWithIcon(
  48. GUIContent content,
  49. Vector2 contentSize,
  50. float offsetX,
  51. float offsetY,
  52. Texture2D icon)
  53. {
  54. int iconSize = UnityConstants.TREEVIEW_STATUS_ICON_SIZE;
  55. int padding = UnityConstants.TREEVIEW_STATUS_CONTENT_PADDING;
  56. float iconOffsetX = offsetX - iconSize + padding;
  57. float contentOffsetX = offsetX + iconSize - padding;
  58. GUI.DrawTexture(
  59. new Rect(iconOffsetX, offsetY + padding, iconSize, iconSize),
  60. icon,
  61. ScaleMode.ScaleToFit);
  62. DrawLabel(
  63. content,
  64. contentSize,
  65. contentOffsetX,
  66. offsetY);
  67. }
  68. static Vector2 GetContentSize(GUIContent content)
  69. {
  70. return ((GUIStyle)UnityStyles.Tree.StatusLabel).CalcSize(content);
  71. }
  72. }
  73. }