using UnityEngine; using UnityEngine.UIElements; namespace AssetBank.DockableWindow.UIHelper { // 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; } // Overload for creating a Toggle with an initial value and a callback. public static Toggle CreateToggle(string label, bool value, System.Action> callback) { var toggle = new Toggle(label) { value = value, style = { marginTop = 2 } }; toggle.RegisterValueChangedCallback(evt => callback(evt)); return toggle; } // Creates the "Generate" button. public static Button CreateGenerateButton(bool showGenerateAll = false) { var button = new Button { text = showGenerateAll ? "Generate All" : "Generate", style = { height = 30, marginTop = 20, backgroundColor = new StyleColor(new Color(0.2f, 0.6f, 0.2f)) } }; return button; } // Creates a separator line. public static VisualElement CreateSeparator() { return new VisualElement { style = { flexDirection = FlexDirection.Row, alignItems = Align.Center, marginTop = 10, marginBottom = 10, height = 1, backgroundColor = new Color(0.5f, 0.5f, 0.5f) } }; } } }