1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- using UnityEditor;
- using UnityEngine;
- using UnityEngine.UIElements;
- namespace ProjectExporter
- {
- // This class provides static methods to create styled visual elements for the editor window.
- public static class ProjectExporterUI
- {
- // Creates a main container for a tab's content.
- public static VisualElement CreateMainContainer()
- {
- return new VisualElement
- {
- style =
- {
- paddingLeft = 10,
- paddingRight = 10,
- paddingTop = 10,
- paddingBottom = 10
- }
- };
- }
- // Creates a tab button.
- public static Button CreateTab(string label)
- {
- var button = new Button
- {
- text = label,
- style =
- {
- flexGrow = 1,
- borderBottomWidth = 1,
- borderBottomColor = Color.gray,
- marginLeft = 0,
- marginRight = 0
- }
- };
- return button;
- }
- // Creates a Foldout element for hierarchical display.
- public static Foldout CreateFoldout(string text)
- {
- var foldout = new Foldout
- {
- text = text,
- value = false, // Start collapsed
- style =
- {
- marginTop = 5
- }
- };
- return foldout;
- }
- // Creates a Toggle for selecting an asset.
- public static Toggle CreateToggle(string label)
- {
- var toggle = new Toggle
- {
- text = label,
- style =
- {
- marginTop = 2
- }
- };
- return toggle;
- }
- // Creates the "Generate" button.
- public static Button CreateGenerateButton()
- {
- var button = new Button
- {
- text = "Generate",
- style =
- {
- height = 30,
- marginTop = 20,
- backgroundColor = new StyleColor(new Color(0.2f, 0.6f, 0.2f))
- }
- };
- return button;
- }
- }
- }
|