diff --git a/ContentExplorer.meta b/ContentExplorer.meta new file mode 100644 index 0000000..3fb9058 --- /dev/null +++ b/ContentExplorer.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3d54f69fd90050e41a745774b685bce3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ContentExplorer/ContentExplorerDemo.cs b/ContentExplorer/ContentExplorerDemo.cs new file mode 100644 index 0000000..5b127e4 --- /dev/null +++ b/ContentExplorer/ContentExplorerDemo.cs @@ -0,0 +1,198 @@ +// Examples~/ContentExplorer/ContentExplorerDemo.cs +// Demonstrates: CollapsibleSection, IconLabelButton, LoadingIcon +// +// Scene setup: +// 1. Open the provided ContentExplorer scene (the UIDocument and this +// ContentExplorerDemo component live on the same GameObject; the demo +// resolves the UIDocument via GetComponent() at runtime). +// 2. Press Play — a loading spinner blocks interaction for 1.5 s, then three +// collapsible accordion sections appear. Tap any row to see which item was selected. + +using System.Collections; +using UnityEngine; +using UnityEngine.UIElements; +using UnityUIToolkit.Extensions; + +namespace UnityUIToolkit.Extensions.Examples +{ + /// + /// Content explorer demo showcasing , + /// , and . + /// + /// On Start a full-screen loading overlay is displayed using + /// which blocks pointer events (blockInteraction: true). + /// After 1.5 seconds the spinner is stopped and the three collapsible sections + /// are revealed with a simple fade-in. + /// + /// Each section contains several rows. + /// Clicking a row writes the selection into the status label at the bottom. + /// + public class ContentExplorerDemo : MonoBehaviour + { + private static readonly (string section, string[] items)[] SectionData = + { + ( + "Getting Started", + new[] + { + "Introduction to UI Toolkit", + "Your first VisualElement", + "Styling with USS classes", + "Working with events", + } + ), + ( + "Controls", + new[] + { + "PillButton — gradient actions", + "PillInputField — mobile-ready input", + "ScrollSnap — paging container", + "QuadrantStepper — segmented navigation", + } + ), + ( + "Utilities", + new[] + { + "VisualElementShakeUtility", + "UIToolkitExtensions helpers", + "ToastSwipeDismissManipulator", + } + ), + }; + + private UIDocument uiDocument; + private LoadingIcon loadingIcon; + private VisualElement contentScroll; + private Label statusLabel; + private Texture2D spinnerTexture; + + private void Start() + { + uiDocument = GetComponent(); + if (uiDocument == null) + { + Debug.LogError("ContentExplorerDemo requires a UIDocument on the same GameObject.", this); + return; + } + + VisualElement root = uiDocument.rootVisualElement; + root.Clear(); + BuildUI(root); + } + + private void OnDestroy() + { + if (spinnerTexture != null) + Destroy(spinnerTexture); + } + + private void BuildUI(VisualElement root) + { + var screen = UIToolkitExtensions.CreateVisualElement(root, "contentExplorer__screen"); + + var card = UIToolkitExtensions.CreateVisualElement(screen, "contentExplorer__card"); + + var eyebrow = UIToolkitExtensions.CreateVisualElement