123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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<ChangeEvent<bool>> 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;
- }
- }
- }
|