Columns.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. using System;
  6. namespace UnityEditor.Performance.ProfileAnalyzer
  7. {
  8. internal class Columns
  9. {
  10. int[] m_ColumnWidth = new int[4];
  11. public Columns(int a, int b, int c, int d)
  12. {
  13. SetColumnSizes(a, b, c, d);
  14. }
  15. public void SetColumnSizes(int a, int b, int c, int d)
  16. {
  17. m_ColumnWidth[0] = a;
  18. m_ColumnWidth[1] = b;
  19. m_ColumnWidth[2] = c;
  20. m_ColumnWidth[3] = d;
  21. }
  22. public int GetColumnWidth(int n)
  23. {
  24. if (n < 0 || n >= m_ColumnWidth.Length)
  25. return 0;
  26. return m_ColumnWidth[n];
  27. }
  28. public void Draw(int n, string col)
  29. {
  30. if (n < 0 || n >= m_ColumnWidth.Length || m_ColumnWidth[n] <= 0)
  31. EditorGUILayout.LabelField(col);
  32. EditorGUILayout.LabelField(col, GUILayout.Width(m_ColumnWidth[n]));
  33. }
  34. public void Draw(int n, float value)
  35. {
  36. Draw(n, string.Format("{0:f2}", value));
  37. }
  38. public void Draw2(string col1, string col2)
  39. {
  40. EditorGUILayout.BeginHorizontal();
  41. Draw(0, col1);
  42. Draw(1, col2);
  43. EditorGUILayout.EndHorizontal();
  44. }
  45. public void Draw2(string label, float value)
  46. {
  47. EditorGUILayout.BeginHorizontal();
  48. Draw(0, label);
  49. Draw(1, value);
  50. EditorGUILayout.EndHorizontal();
  51. }
  52. public void Draw3(string col1, string col2, string col3)
  53. {
  54. EditorGUILayout.BeginHorizontal();
  55. Draw(0, col1);
  56. Draw(1, col2);
  57. Draw(2, col3);
  58. EditorGUILayout.EndHorizontal();
  59. }
  60. public void Draw3(string col1, float value2, float value3)
  61. {
  62. EditorGUILayout.BeginHorizontal();
  63. Draw(0, col1);
  64. Draw(1, value2);
  65. Draw(2, value3);
  66. EditorGUILayout.EndHorizontal();
  67. }
  68. public void Draw4(string col1, string col2, string col3, string col4)
  69. {
  70. EditorGUILayout.BeginHorizontal();
  71. Draw(0, col1);
  72. Draw(1, col2);
  73. Draw(2, col3);
  74. Draw(3, col4);
  75. EditorGUILayout.EndHorizontal();
  76. }
  77. public void Draw4Diff(string col1, float left, float right)
  78. {
  79. EditorGUILayout.BeginHorizontal();
  80. Draw(0, col1);
  81. Draw(1, left);
  82. Draw(2, right);
  83. Draw(3, right - left);
  84. EditorGUILayout.EndHorizontal();
  85. }
  86. public void Draw4(string col1, float value2, float value3, float value4)
  87. {
  88. EditorGUILayout.BeginHorizontal();
  89. Draw(0, col1);
  90. Draw(1, value2);
  91. Draw(2, value3);
  92. Draw(3, value4);
  93. EditorGUILayout.EndHorizontal();
  94. }
  95. // GUIContent versions
  96. public void Draw(int n, GUIContent col)
  97. {
  98. if (n < 0 || n >= m_ColumnWidth.Length || m_ColumnWidth[n] <= 0)
  99. EditorGUILayout.LabelField(col);
  100. EditorGUILayout.LabelField(col, GUILayout.Width(m_ColumnWidth[n]));
  101. }
  102. public void Draw2(GUIContent col1, GUIContent col2)
  103. {
  104. EditorGUILayout.BeginHorizontal();
  105. Draw(0, col1);
  106. Draw(1, col2);
  107. EditorGUILayout.EndHorizontal();
  108. }
  109. public void Draw2(GUIContent label, float value)
  110. {
  111. EditorGUILayout.BeginHorizontal();
  112. Draw(0, label);
  113. Draw(1, value);
  114. EditorGUILayout.EndHorizontal();
  115. }
  116. public void Draw3(GUIContent col1, GUIContent col2, GUIContent col3)
  117. {
  118. EditorGUILayout.BeginHorizontal();
  119. Draw(0, col1);
  120. Draw(1, col2);
  121. Draw(2, col3);
  122. EditorGUILayout.EndHorizontal();
  123. }
  124. public void Draw3(GUIContent col1, float value2, float value3)
  125. {
  126. EditorGUILayout.BeginHorizontal();
  127. Draw(0, col1);
  128. Draw(1, value2);
  129. Draw(2, value3);
  130. EditorGUILayout.EndHorizontal();
  131. }
  132. public void Draw4(GUIContent col1, GUIContent col2, GUIContent col3, GUIContent col4)
  133. {
  134. EditorGUILayout.BeginHorizontal();
  135. Draw(0, col1);
  136. Draw(1, col2);
  137. Draw(2, col3);
  138. Draw(3, col4);
  139. EditorGUILayout.EndHorizontal();
  140. }
  141. public void Draw4Diff(GUIContent col1, float left, float right)
  142. {
  143. EditorGUILayout.BeginHorizontal();
  144. Draw(0, col1);
  145. Draw(1, left);
  146. Draw(2, right);
  147. Draw(3, right - left);
  148. EditorGUILayout.EndHorizontal();
  149. }
  150. public void Draw4(GUIContent col1, float value2, float value3, float value4)
  151. {
  152. EditorGUILayout.BeginHorizontal();
  153. Draw(0, col1);
  154. Draw(1, value2);
  155. Draw(2, value3);
  156. Draw(3, value4);
  157. EditorGUILayout.EndHorizontal();
  158. }
  159. }
  160. }