ProjectExporterUI.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using UnityEditor;
  2. using UnityEngine;
  3. using UnityEngine.UIElements;
  4. namespace ProjectExporter
  5. {
  6. // This class provides static methods to create styled visual elements for the editor window.
  7. public static class ProjectExporterUI
  8. {
  9. // Creates a main container for a tab's content.
  10. public static VisualElement CreateMainContainer()
  11. {
  12. return new VisualElement
  13. {
  14. style =
  15. {
  16. paddingLeft = 10,
  17. paddingRight = 10,
  18. paddingTop = 10,
  19. paddingBottom = 10
  20. }
  21. };
  22. }
  23. // Creates a tab button.
  24. public static Button CreateTab(string label)
  25. {
  26. var button = new Button
  27. {
  28. text = label,
  29. style =
  30. {
  31. flexGrow = 1,
  32. borderBottomWidth = 1,
  33. borderBottomColor = Color.gray,
  34. marginLeft = 0,
  35. marginRight = 0
  36. }
  37. };
  38. return button;
  39. }
  40. // Creates a Foldout element for hierarchical display.
  41. public static Foldout CreateFoldout(string text)
  42. {
  43. var foldout = new Foldout
  44. {
  45. text = text,
  46. value = false, // Start collapsed
  47. style =
  48. {
  49. marginTop = 5
  50. }
  51. };
  52. return foldout;
  53. }
  54. // Creates a Toggle for selecting an asset.
  55. public static Toggle CreateToggle(string label)
  56. {
  57. var toggle = new Toggle
  58. {
  59. text = label,
  60. style =
  61. {
  62. marginTop = 2
  63. }
  64. };
  65. return toggle;
  66. }
  67. // Creates the "Generate" button.
  68. public static Button CreateGenerateButton()
  69. {
  70. var button = new Button
  71. {
  72. text = "Generate",
  73. style =
  74. {
  75. height = 30,
  76. marginTop = 20,
  77. backgroundColor = new StyleColor(new Color(0.2f, 0.6f, 0.2f))
  78. }
  79. };
  80. return button;
  81. }
  82. }
  83. }