Skip to content

Theme System Implementation and Editor Configuration with Live Preview#6

Open
onuralpyilkin wants to merge 13 commits into
sinanata:mainfrom
onuralpyilkin:main
Open

Theme System Implementation and Editor Configuration with Live Preview#6
onuralpyilkin wants to merge 13 commits into
sinanata:mainfrom
onuralpyilkin:main

Conversation

@onuralpyilkin

Copy link
Copy Markdown
Contributor

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

image image

Checklist

  • Rule uses tokens, no inline hex / px / ms (except where commented as load-bearing).
  • Showcase UXML updated with all states / variants of the new rule.
  • No var(...) in inline UXML style="..." attributes (use a class).
  • Mobile.uss updated if the component has a touch-tier override.
  • docs/COMPONENTS.md line added (or relevant doc updated).
  • CHANGELOG.md entry under the unreleased section.
  • No using LeapOfLegends.* or product-specific imports in C# changes.
  • No Resources.Load<Texture2D> in new C# (icons resolve via USS resource(...)).
  • Tested in the editor with the showcase scene, at desktop and .mobile widths.
  • Tested via Tools\Build\Build-Showcase.ps1 -Serve and confirmed the rendered WebGL build matches the editor.

…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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Assets/DesignSystem/Runtime/Theme/Applier/ThemeApplierBase.cs
Comment thread Assets/DesignSystem/Runtime/Theme/Data/ThemeData.cs
Comment on lines +178 to +191
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();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@onuralpyilkin

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant