Theme System Implementation and Editor Configuration with Live Preview#6
Theme System Implementation and Editor Configuration with Live Preview#6onuralpyilkin wants to merge 13 commits into
Conversation
…r` with updated directory organization
…ditor support - Introduced `ThemeData` for central theme management. - Added generic `ThemeApplierBase<TComponent>` with `UIDocument` and `PanelRenderer` implementations. - Includes editor utilities for theme asset inspection, editing, and embedding `uss` stylesheets.
- Implemented an editor window for editing `ThemeData` assets and previewing changes in real-time.
…r, because the package doesn't have some Showcase related assets
…review.uxml` to use in ThemeConfiguratorWindow's preview
- Introduced support for selecting custom UXML files for the preview via a new ObjectField. - Saved the selected UXML's GUID to EditorPrefs for persistence. - Added fallback mechanism to use default UXML when custom UXML is unavailable.
…date related documents to contain new project structure.
There was a problem hiding this comment.
Code Review
This pull request introduces a robust theme-authoring pipeline to the design system, including a ThemeData asset for token storage, a split-pane ThemeConfiguratorWindow with a live preview, and ThemeApplier components for runtime theme swapping. It also restructures the core runtime helper into DesignSystemBehaviour and cleans up the package structure. The review identified several critical issues that must be addressed: a compilation error in the OnOpenAsset signature within ThemeConfiguratorWindow.cs, a stylesheet leak in ThemeApplierBase.cs during theme swaps, invalid USS generation for transition durations in ThemeData.cs, dead code in ThemeApplier.cs when the root element is null, and a disruptive blocking dialog in ThemeDataEditor.cs's OnDisable method.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| private void OnDisable() | ||
| { | ||
| var theme = (ThemeData)target; | ||
| if (!theme) return; | ||
|
|
||
| if (!EditorUtility.IsDirty(theme) && !_hadChanges) return; | ||
| var save = EditorUtility.DisplayDialog( | ||
| "Unsaved Changes", | ||
| $"'{theme.name}' has unsaved changes.\nDo you want to save before closing?", | ||
| "Save", "Revert"); | ||
|
|
||
| if (save) Save(); | ||
| else Revert(); | ||
| } |
There was a problem hiding this comment.
Usability/Stability Issue: Displaying a blocking dialog (EditorUtility.DisplayDialog) inside OnDisable() of a custom editor is highly disruptive and discouraged in Unity. It triggers on simple selection changes (clicking away from the asset), interrupting the user's workflow and potentially causing GUI layout errors. Since the asset is already marked dirty via EditorUtility.SetDirty, Unity will automatically handle prompting the user to save when saving the project or closing.
Fix: Remove the OnDisable method entirely.
There was a problem hiding this comment.
This actually needed, it will not make a big problem. When a user change something and didn't save it, it will be saved on another save action (for example scene save). So we need to warn user when focus lose. This is how unity handles FBX assets, if you change a parameter then focus on something else, you will immediately prompted.
|
Btw, I think there is some misunderstandings about Panel Renderer. UI Document has been deprecated and no longer will get update, from now on Panel Renderer is the only component that needs to be used. About World-Space UI's, it's possible to make them with UI Document too, so that means Panel Renderer isn't the only way to go. But as I said, UI Document is deprecated and Panel Renderer should be used for both Flat UI's and World-Space UI's. |
- Implement preprocessor directives to handle Unity version-specific differences in `OnOpenAsset` method.
Summary
Theme-authoring pipeline for the design system, a ThemeData ScriptableObject stores every token, a split-pane ThemeConfiguratorWindow previews changes live, and a ThemeApplier component swaps themes at runtime. The runtime is renamed from DesignSystemRuntime to DesignSystemBehaviour and the directory layout is cleaned up. Showcase UXML moved out of the package folder (It had dependencies on assets that weren't included in the package.) and instead created simplified Theme Preview UXML for Theme Configurator.
Screenshots
Checklist
var(...)in inline UXMLstyle="..."attributes (use a class).Mobile.ussupdated if the component has a touch-tier override.docs/COMPONENTS.mdline added (or relevant doc updated).CHANGELOG.mdentry under the unreleased section.using LeapOfLegends.*or product-specific imports in C# changes.Resources.Load<Texture2D>in new C# (icons resolve via USSresource(...))..mobilewidths.Tools\Build\Build-Showcase.ps1 -Serveand confirmed the rendered WebGL build matches the editor.