DebugUIDrawer.Builtins.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.Rendering;
  4. namespace UnityEditor.Rendering
  5. {
  6. /// <summary>
  7. /// Builtin Drawer for Value Debug Items.
  8. /// </summary>
  9. [DebugUIDrawer(typeof(DebugUI.Value))]
  10. public sealed class DebugUIDrawerValue : DebugUIDrawer
  11. {
  12. /// <summary>
  13. /// OnGUI implementation for Value DebugUIDrawer.
  14. /// </summary>
  15. /// <param name="widget">DebugUI Widget.</param>
  16. /// <param name="state">Debug State associated with the Debug Item.</param>
  17. /// <returns>The state of the widget.</returns>
  18. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  19. {
  20. var w = Cast<DebugUI.Value>(widget);
  21. var rect = PrepareControlRect();
  22. EditorGUI.LabelField(rect, EditorGUIUtility.TrTextContent(w.displayName), EditorGUIUtility.TrTextContent(w.GetValue().ToString()));
  23. return true;
  24. }
  25. }
  26. /// <summary>
  27. /// Builtin Drawer for Button Debug Items.
  28. /// </summary>
  29. [DebugUIDrawer(typeof(DebugUI.Button))]
  30. public sealed class DebugUIDrawerButton : DebugUIDrawer
  31. {
  32. /// <summary>
  33. /// OnGUI implementation for Button DebugUIDrawer.
  34. /// </summary>
  35. /// <param name="widget">DebugUI Widget.</param>
  36. /// <param name="state">Debug State associated with the Debug Item.</param>
  37. /// <returns>The state of the widget.</returns>
  38. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  39. {
  40. var w = Cast<DebugUI.Button>(widget);
  41. var rect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect());
  42. if (GUI.Button(rect, w.displayName, EditorStyles.miniButton))
  43. {
  44. if (w.action != null)
  45. w.action();
  46. }
  47. return true;
  48. }
  49. }
  50. /// <summary>
  51. /// Builtin Drawer for Boolean Debug Items.
  52. /// </summary>
  53. [DebugUIDrawer(typeof(DebugUI.BoolField))]
  54. public sealed class DebugUIDrawerBoolField : DebugUIDrawer
  55. {
  56. /// <summary>
  57. /// OnGUI implementation for Boolean DebugUIDrawer.
  58. /// </summary>
  59. /// <param name="widget">DebugUI Widget.</param>
  60. /// <param name="state">Debug State associated with the Debug Item.</param>
  61. /// <returns>The state of the widget.</returns>
  62. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  63. {
  64. var w = Cast<DebugUI.BoolField>(widget);
  65. var s = Cast<DebugStateBool>(state);
  66. EditorGUI.BeginChangeCheck();
  67. var rect = PrepareControlRect();
  68. bool value = EditorGUI.Toggle(rect, EditorGUIUtility.TrTextContent(w.displayName), w.GetValue());
  69. if (EditorGUI.EndChangeCheck())
  70. Apply(w, s, value);
  71. return true;
  72. }
  73. }
  74. /// <summary>
  75. /// Builtin Drawer for History Boolean Debug Items.
  76. /// </summary>
  77. [DebugUIDrawer(typeof(DebugUI.HistoryBoolField))]
  78. public sealed class DebugUIDrawerHistoryBoolField : DebugUIDrawer
  79. {
  80. /// <summary>
  81. /// OnGUI implementation for History Boolean DebugUIDrawer.
  82. /// </summary>
  83. /// <param name="widget">DebugUI Widget.</param>
  84. /// <param name="state">Debug State associated with the Debug Item.</param>
  85. /// <returns>The state of the widget.</returns>
  86. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  87. {
  88. var w = Cast<DebugUI.HistoryBoolField>(widget);
  89. var s = Cast<DebugStateBool>(state);
  90. EditorGUI.BeginChangeCheck();
  91. var rect = PrepareControlRect();
  92. var labelRect = rect;
  93. labelRect.width = EditorGUIUtility.labelWidth;
  94. const int oneValueWidth = 70;
  95. var valueRects = new Rect[w.historyDepth + 1];
  96. for(int i = 0; i < w.historyDepth + 1; i++)
  97. {
  98. valueRects[i] = rect;
  99. valueRects[i].x += EditorGUIUtility.labelWidth + i * oneValueWidth;
  100. valueRects[i].width = oneValueWidth;
  101. }
  102. EditorGUI.LabelField(labelRect, EditorGUIUtility.TrTextContent(w.displayName));
  103. int indent = EditorGUI.indentLevel;
  104. EditorGUI.indentLevel = 0; //be at left of rects
  105. bool value = EditorGUI.Toggle(valueRects[0], w.GetValue());
  106. using (new EditorGUI.DisabledScope(true))
  107. {
  108. for (int i = 0; i < w.historyDepth; i++)
  109. EditorGUI.Toggle(valueRects[i + 1], w.GetHistoryValue(i));
  110. }
  111. EditorGUI.indentLevel = indent;
  112. if (EditorGUI.EndChangeCheck())
  113. Apply(w, s, value);
  114. return true;
  115. }
  116. }
  117. /// <summary>
  118. /// Builtin Drawer for Integer Debug Items.
  119. /// </summary>
  120. [DebugUIDrawer(typeof(DebugUI.IntField))]
  121. public sealed class DebugUIDrawerIntField : DebugUIDrawer
  122. {
  123. /// <summary>
  124. /// OnGUI implementation for Integer DebugUIDrawer.
  125. /// </summary>
  126. /// <param name="widget">DebugUI Widget.</param>
  127. /// <param name="state">Debug State associated with the Debug Item.</param>
  128. /// <returns>The state of the widget.</returns>
  129. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  130. {
  131. var w = Cast<DebugUI.IntField>(widget);
  132. var s = Cast<DebugStateInt>(state);
  133. EditorGUI.BeginChangeCheck();
  134. var rect = PrepareControlRect();
  135. int value = w.min != null && w.max != null
  136. ? EditorGUI.IntSlider(rect, EditorGUIUtility.TrTextContent(w.displayName), w.GetValue(), w.min(), w.max())
  137. : EditorGUI.IntField(rect, EditorGUIUtility.TrTextContent(w.displayName), w.GetValue());
  138. if (EditorGUI.EndChangeCheck())
  139. Apply(w, s, value);
  140. return true;
  141. }
  142. }
  143. /// <summary>
  144. /// Builtin Drawer for Unsigned Integer Debug Items.
  145. /// </summary>
  146. [DebugUIDrawer(typeof(DebugUI.UIntField))]
  147. public sealed class DebugUIDrawerUIntField : DebugUIDrawer
  148. {
  149. /// <summary>
  150. /// OnGUI implementation for Unsigned Integer DebugUIDrawer.
  151. /// </summary>
  152. /// <param name="widget">DebugUI Widget.</param>
  153. /// <param name="state">Debug State associated with the Debug Item.</param>
  154. /// <returns>The state of the widget.</returns>
  155. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  156. {
  157. var w = Cast<DebugUI.UIntField>(widget);
  158. var s = Cast<DebugStateUInt>(state);
  159. EditorGUI.BeginChangeCheck();
  160. // No UIntField so we need to max to 0 ourselves or the value will wrap around
  161. var rect = PrepareControlRect();
  162. int tmp = w.min != null && w.max != null
  163. ? EditorGUI.IntSlider(rect, EditorGUIUtility.TrTextContent(w.displayName), Mathf.Max(0, (int)w.GetValue()), Mathf.Max(0, (int)w.min()), Mathf.Max(0, (int)w.max()))
  164. : EditorGUI.IntField(rect, EditorGUIUtility.TrTextContent(w.displayName), Mathf.Max(0, (int)w.GetValue()));
  165. uint value = (uint)Mathf.Max(0, tmp);
  166. if (EditorGUI.EndChangeCheck())
  167. Apply(w, s, value);
  168. return true;
  169. }
  170. }
  171. /// <summary>
  172. /// Builtin Drawer for Float Debug Items.
  173. /// </summary>
  174. [DebugUIDrawer(typeof(DebugUI.FloatField))]
  175. public sealed class DebugUIDrawerFloatField : DebugUIDrawer
  176. {
  177. /// <summary>
  178. /// OnGUI implementation for Float DebugUIDrawer.
  179. /// </summary>
  180. /// <param name="widget">DebugUI Widget.</param>
  181. /// <param name="state">Debug State associated with the Debug Item.</param>
  182. /// <returns>The state of the widget.</returns>
  183. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  184. {
  185. var w = Cast<DebugUI.FloatField>(widget);
  186. var s = Cast<DebugStateFloat>(state);
  187. EditorGUI.BeginChangeCheck();
  188. var rect = PrepareControlRect();
  189. float value = w.min != null && w.max != null
  190. ? EditorGUI.Slider(rect, EditorGUIUtility.TrTextContent(w.displayName), w.GetValue(), w.min(), w.max())
  191. : EditorGUI.FloatField(rect, EditorGUIUtility.TrTextContent(w.displayName), w.GetValue());
  192. if (EditorGUI.EndChangeCheck())
  193. Apply(w, s, value);
  194. return true;
  195. }
  196. }
  197. /// <summary>
  198. /// Builtin Drawer for Enum Debug Items.
  199. /// </summary>
  200. [DebugUIDrawer(typeof(DebugUI.EnumField))]
  201. public sealed class DebugUIDrawerEnumField : DebugUIDrawer
  202. {
  203. /// <summary>
  204. /// OnGUI implementation for Enum DebugUIDrawer.
  205. /// </summary>
  206. /// <param name="widget">DebugUI Widget.</param>
  207. /// <param name="state">Debug State associated with the Debug Item.</param>
  208. /// <returns>The state of the widget.</returns>
  209. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  210. {
  211. var w = Cast<DebugUI.EnumField>(widget);
  212. var s = Cast<DebugStateInt>(state);
  213. if (w.indexes == null)
  214. w.InitIndexes();
  215. EditorGUI.BeginChangeCheck();
  216. int index = -1;
  217. int value = w.GetValue();
  218. if (w.enumNames == null || w.enumValues == null)
  219. {
  220. EditorGUILayout.LabelField("Can't draw an empty enumeration.");
  221. }
  222. else
  223. {
  224. var rect = PrepareControlRect();
  225. index = w.currentIndex;
  226. // Fallback just in case, we may be handling sub/sectionned enums here
  227. if (index < 0)
  228. index = 0;
  229. index = EditorGUI.IntPopup(rect, EditorGUIUtility.TrTextContent(w.displayName), index, w.enumNames, w.indexes);
  230. value = w.enumValues[index];
  231. }
  232. if (EditorGUI.EndChangeCheck())
  233. {
  234. Apply(w, s, value);
  235. if (index > -1)
  236. w.currentIndex = index;
  237. }
  238. return true;
  239. }
  240. }
  241. /// <summary>
  242. /// Builtin Drawer for History Enum Debug Items.
  243. /// </summary>
  244. [DebugUIDrawer(typeof(DebugUI.HistoryEnumField))]
  245. public sealed class DebugUIDrawerHistoryEnumField : DebugUIDrawer
  246. {
  247. /// <summary>
  248. /// OnGUI implementation for History Enum DebugUIDrawer.
  249. /// </summary>
  250. /// <param name="widget">DebugUI Widget.</param>
  251. /// <param name="state">Debug State associated with the Debug Item.</param>
  252. /// <returns>The state of the widget.</returns>
  253. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  254. {
  255. var w = Cast<DebugUI.HistoryEnumField>(widget);
  256. var s = Cast<DebugStateInt>(state);
  257. if (w.indexes == null)
  258. w.InitIndexes();
  259. EditorGUI.BeginChangeCheck();
  260. int index = -1;
  261. int value = w.GetValue();
  262. if (w.enumNames == null || w.enumValues == null)
  263. {
  264. EditorGUILayout.LabelField("Can't draw an empty enumeration.");
  265. }
  266. else
  267. {
  268. var rect = PrepareControlRect();
  269. index = w.currentIndex;
  270. // Fallback just in case, we may be handling sub/sectionned enums here
  271. if (index < 0)
  272. index = 0;
  273. var labelRect = rect;
  274. labelRect.width = EditorGUIUtility.labelWidth;
  275. const int oneValueWidth = 70;
  276. var valueRects = new Rect[w.historyDepth + 1];
  277. for (int i = 0; i < w.historyDepth + 1; i++)
  278. {
  279. valueRects[i] = rect;
  280. valueRects[i].x += EditorGUIUtility.labelWidth + i * oneValueWidth;
  281. valueRects[i].width = oneValueWidth;
  282. }
  283. EditorGUI.LabelField(labelRect, EditorGUIUtility.TrTextContent(w.displayName));
  284. int indent = EditorGUI.indentLevel;
  285. EditorGUI.indentLevel = 0; //be at left of rects
  286. index = EditorGUI.IntPopup(valueRects[0], index, w.enumNames, w.indexes);
  287. value = w.enumValues[index];
  288. using (new EditorGUI.DisabledScope(true))
  289. {
  290. for (int i = 0; i < w.historyDepth; i++)
  291. EditorGUI.IntPopup(valueRects[i + 1], w.GetHistoryValue(i), w.enumNames, w.indexes);
  292. }
  293. EditorGUI.indentLevel = indent;
  294. }
  295. if (EditorGUI.EndChangeCheck())
  296. {
  297. Apply(w, s, value);
  298. if (index > -1)
  299. w.currentIndex = index;
  300. }
  301. return true;
  302. }
  303. }
  304. /// <summary>
  305. /// Builtin Drawer for Bitfield Debug Items.
  306. /// </summary>
  307. [DebugUIDrawer(typeof(DebugUI.BitField))]
  308. public sealed class DebugUIDrawerBitField : DebugUIDrawer
  309. {
  310. /// <summary>
  311. /// OnGUI implementation for Bitfield DebugUIDrawer.
  312. /// </summary>
  313. /// <param name="widget">DebugUI Widget.</param>
  314. /// <param name="state">Debug State associated with the Debug Item.</param>
  315. /// <returns>The state of the widget.</returns>
  316. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  317. {
  318. var w = Cast<DebugUI.BitField>(widget);
  319. var s = Cast<DebugStateFlags>(state);
  320. EditorGUI.BeginChangeCheck();
  321. Enum value = w.GetValue();
  322. var rect = PrepareControlRect();
  323. value = EditorGUI.EnumFlagsField(rect, EditorGUIUtility.TrTextContent(w.displayName), value);
  324. if (EditorGUI.EndChangeCheck())
  325. Apply(w, s, value);
  326. return true;
  327. }
  328. }
  329. /// <summary>
  330. /// Builtin Drawer for Foldout Debug Items.
  331. /// </summary>
  332. [DebugUIDrawer(typeof(DebugUI.Foldout))]
  333. public sealed class DebugUIDrawerFoldout : DebugUIDrawer
  334. {
  335. /// <summary>
  336. /// Begin implementation for Foldout DebugUIDrawer.
  337. /// </summary>
  338. /// <param name="widget">DebugUI Widget.</param>
  339. /// <param name="state">Debug State associated with the Debug Item.</param>
  340. public override void Begin(DebugUI.Widget widget, DebugState state)
  341. {
  342. var w = Cast<DebugUI.Foldout>(widget);
  343. var s = Cast<DebugStateBool>(state);
  344. EditorGUI.BeginChangeCheck();
  345. Rect rect = PrepareControlRect();
  346. bool value = EditorGUI.Foldout(rect, w.GetValue(), EditorGUIUtility.TrTextContent(w.displayName), true);
  347. Rect drawRect = GUILayoutUtility.GetLastRect();
  348. if (w.columnLabels != null && value)
  349. {
  350. const int oneColumnWidth = 70;
  351. int indent = EditorGUI.indentLevel;
  352. EditorGUI.indentLevel = 0; //be at left of rects
  353. for (int i = 0; i < w.columnLabels.Length; i++)
  354. {
  355. var columnRect = drawRect;
  356. columnRect.x += EditorGUIUtility.labelWidth + i * oneColumnWidth;
  357. columnRect.width = oneColumnWidth;
  358. EditorGUI.LabelField(columnRect, w.columnLabels[i] ?? "", EditorStyles.miniBoldLabel);
  359. }
  360. EditorGUI.indentLevel = indent;
  361. }
  362. if (EditorGUI.EndChangeCheck())
  363. Apply(w, s, value);
  364. EditorGUI.indentLevel++;
  365. }
  366. /// <summary>
  367. /// OnGUI implementation for Foldout DebugUIDrawer.
  368. /// </summary>
  369. /// <param name="widget">DebugUI Widget.</param>
  370. /// <param name="state">Debug State associated with the Debug Item.</param>
  371. /// <returns>The state of the widget.</returns>
  372. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  373. {
  374. var s = Cast<DebugStateBool>(state);
  375. return s.value;
  376. }
  377. /// <summary>
  378. /// End implementation for Foldout DebugUIDrawer.
  379. /// </summary>
  380. /// <param name="widget">DebugUI Widget.</param>
  381. /// <param name="state">Debug State associated with the Debug Item.</param>
  382. public override void End(DebugUI.Widget widget, DebugState state)
  383. {
  384. EditorGUI.indentLevel--;
  385. }
  386. }
  387. /// <summary>
  388. /// Builtin Drawer for Color Debug Items.
  389. /// </summary>
  390. [DebugUIDrawer(typeof(DebugUI.ColorField))]
  391. public sealed class DebugUIDrawerColorField : DebugUIDrawer
  392. {
  393. /// <summary>
  394. /// OnGUI implementation for Color DebugUIDrawer.
  395. /// </summary>
  396. /// <param name="widget">DebugUI Widget.</param>
  397. /// <param name="state">Debug State associated with the Debug Item.</param>
  398. /// <returns>The state of the widget.</returns>
  399. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  400. {
  401. var w = Cast<DebugUI.ColorField>(widget);
  402. var s = Cast<DebugStateColor>(state);
  403. EditorGUI.BeginChangeCheck();
  404. var rect = PrepareControlRect();
  405. var value = EditorGUI.ColorField(rect, EditorGUIUtility.TrTextContent(w.displayName), w.GetValue(), w.showPicker, w.showAlpha, w.hdr);
  406. if (EditorGUI.EndChangeCheck())
  407. Apply(w, s, value);
  408. return true;
  409. }
  410. }
  411. /// <summary>
  412. /// Builtin Drawer for Vector2 Debug Items.
  413. /// </summary>
  414. [DebugUIDrawer(typeof(DebugUI.Vector2Field))]
  415. public sealed class DebugUIDrawerVector2Field : DebugUIDrawer
  416. {
  417. /// <summary>
  418. /// OnGUI implementation for Vector2 DebugUIDrawer.
  419. /// </summary>
  420. /// <param name="widget">DebugUI Widget.</param>
  421. /// <param name="state">Debug State associated with the Debug Item.</param>
  422. /// <returns>The state of the widget.</returns>
  423. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  424. {
  425. var w = Cast<DebugUI.Vector2Field>(widget);
  426. var s = Cast<DebugStateVector2>(state);
  427. EditorGUI.BeginChangeCheck();
  428. var value = EditorGUILayout.Vector2Field(w.displayName, w.GetValue());
  429. if (EditorGUI.EndChangeCheck())
  430. Apply(w, s, value);
  431. return true;
  432. }
  433. }
  434. /// <summary>
  435. /// Builtin Drawer for Vector3 Debug Items.
  436. /// </summary>
  437. [DebugUIDrawer(typeof(DebugUI.Vector3Field))]
  438. public sealed class DebugUIDrawerVector3Field : DebugUIDrawer
  439. {
  440. /// <summary>
  441. /// OnGUI implementation for Vector3 DebugUIDrawer.
  442. /// </summary>
  443. /// <param name="widget">DebugUI Widget.</param>
  444. /// <param name="state">Debug State associated with the Debug Item.</param>
  445. /// <returns>The state of the widget.</returns>
  446. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  447. {
  448. var w = Cast<DebugUI.Vector3Field>(widget);
  449. var s = Cast<DebugStateVector3>(state);
  450. EditorGUI.BeginChangeCheck();
  451. var value = EditorGUILayout.Vector3Field(w.displayName, w.GetValue());
  452. if (EditorGUI.EndChangeCheck())
  453. Apply(w, s, value);
  454. return true;
  455. }
  456. }
  457. /// <summary>
  458. /// Builtin Drawer for Vector4 Debug Items.
  459. /// </summary>
  460. [DebugUIDrawer(typeof(DebugUI.Vector4Field))]
  461. public sealed class DebugUIDrawerVector4Field : DebugUIDrawer
  462. {
  463. /// <summary>
  464. /// OnGUI implementation for Vector4 DebugUIDrawer.
  465. /// </summary>
  466. /// <param name="widget">DebugUI Widget.</param>
  467. /// <param name="state">Debug State associated with the Debug Item.</param>
  468. /// <returns>The state of the widget.</returns>
  469. public override bool OnGUI(DebugUI.Widget widget, DebugState state)
  470. {
  471. var w = Cast<DebugUI.Vector4Field>(widget);
  472. var s = Cast<DebugStateVector4>(state);
  473. EditorGUI.BeginChangeCheck();
  474. var value = EditorGUILayout.Vector4Field(w.displayName, w.GetValue());
  475. if (EditorGUI.EndChangeCheck())
  476. Apply(w, s, value);
  477. return true;
  478. }
  479. }
  480. /// <summary>
  481. /// Builtin Drawer for Container Debug Items.
  482. /// </summary>
  483. [DebugUIDrawer(typeof(DebugUI.Container))]
  484. public sealed class DebugUIDrawerContainer : DebugUIDrawer
  485. {
  486. /// <summary>
  487. /// Begin implementation for Container DebugUIDrawer.
  488. /// </summary>
  489. /// <param name="widget">DebugUI Widget.</param>
  490. /// <param name="state">Debug State associated with the Debug Item.</param>
  491. public override void Begin(DebugUI.Widget widget, DebugState state)
  492. {
  493. if (!string.IsNullOrEmpty(widget.displayName))
  494. EditorGUILayout.LabelField(widget.displayName, EditorStyles.boldLabel);
  495. EditorGUI.indentLevel++;
  496. }
  497. /// <summary>
  498. /// End implementation for Container DebugUIDrawer.
  499. /// </summary>
  500. /// <param name="widget">DebugUI Widget.</param>
  501. /// <param name="state">Debug State associated with the Debug Item.</param>
  502. public override void End(DebugUI.Widget widget, DebugState state)
  503. {
  504. EditorGUI.indentLevel--;
  505. }
  506. }
  507. /// <summary>
  508. /// Builtin Drawer for Horizontal Box Debug Items.
  509. /// </summary>
  510. [DebugUIDrawer(typeof(DebugUI.HBox))]
  511. public sealed class DebugUIDrawerHBox : DebugUIDrawer
  512. {
  513. /// <summary>
  514. /// Begin implementation for Horizontal Box DebugUIDrawer.
  515. /// </summary>
  516. /// <param name="widget">DebugUI Widget.</param>
  517. /// <param name="state">Debug State associated with the Debug Item.</param>
  518. public override void Begin(DebugUI.Widget widget, DebugState state)
  519. {
  520. EditorGUILayout.BeginHorizontal();
  521. }
  522. /// <summary>
  523. /// End implementation for Horizontal Box DebugUIDrawer.
  524. /// </summary>
  525. /// <param name="widget">DebugUI Widget.</param>
  526. /// <param name="state">Debug State associated with the Debug Item.</param>
  527. public override void End(DebugUI.Widget widget, DebugState state)
  528. {
  529. EditorGUILayout.EndHorizontal();
  530. }
  531. }
  532. /// <summary>
  533. /// Builtin Drawer for Vertical Box Debug Items.
  534. /// </summary>
  535. [DebugUIDrawer(typeof(DebugUI.VBox))]
  536. public sealed class DebugUIDrawerVBox : DebugUIDrawer
  537. {
  538. /// <summary>
  539. /// Begin implementation for Vertical Box DebugUIDrawer.
  540. /// </summary>
  541. /// <param name="widget">DebugUI Widget.</param>
  542. /// <param name="state">Debug State associated with the Debug Item.</param>
  543. public override void Begin(DebugUI.Widget widget, DebugState state)
  544. {
  545. EditorGUILayout.BeginVertical();
  546. }
  547. /// <summary>
  548. /// End implementation for Vertical Box DebugUIDrawer.
  549. /// </summary>
  550. /// <param name="widget">DebugUI Widget.</param>
  551. /// <param name="state">Debug State associated with the Debug Item.</param>
  552. public override void End(DebugUI.Widget widget, DebugState state)
  553. {
  554. EditorGUILayout.EndVertical();
  555. }
  556. }
  557. }