Class AppUIThemeAsset
A custom App UI theme, imported from a .appuitheme.json file.
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public class AppUIThemeAsset : ScriptableObject
Remarks
This is the main object of the imported asset, with the two compiled stylesheets stored
alongside it as sub-assets. Making the theme — rather than the stylesheet — the main object
keeps AssetDatabase.FindAssets("t:AppUIThemeAsset") a clean way to enumerate the
custom themes in a project, which is what populates the theme dropdowns.
The type lives in the runtime assembly even though only the editor ever creates one, so that player code can hold a serialized reference to a theme and apply it at run time. Were it editor-only, the usage below would not compile in a build.
To use one, hold a reference to the theme — a serialized field assigned in the inspector — then add its styleSheet to a panel and set the theme name:
[SerializeField] AppUIThemeAsset m_Theme;
void Start()
{
var panel = GetComponent<UIDocument>().rootVisualElement.Q<Panel>();
panel.styleSheets.Add(m_Theme.styleSheet);
panel.theme = m_Theme.themeName;
}
That layers the theme over whatever App UI theme is already loaded, so any token the custom
theme does not define keeps its value from the base theme rather than resolving to nothing.
Assigning themeStyleSheet to PanelSettings.themeStyleSheet instead
replaces the theme file wholesale.
Properties
baseTheme
The App UI theme this one was derived from.
Declaration
public string baseTheme { get; }
Property Value
| Type | Description |
|---|---|
| string |
colorScheme
Whether the theme reads as dark or light.
Declaration
public string colorScheme { get; }
Property Value
| Type | Description |
|---|---|
| string |
displayName
A human-readable name for menus and inspectors.
Declaration
public string displayName { get; }
Property Value
| Type | Description |
|---|---|
| string |
styleSheet
The class-scoped stylesheet, for element.styleSheets.Add(...). This is the
recommended way to apply a custom theme.
Declaration
public StyleSheet styleSheet { get; }
Property Value
| Type | Description |
|---|---|
| StyleSheet |
themeName
The theme's identifier, which is also the value to assign to Panel.theme. The
generated stylesheet defines .appui--<themeName>.
Declaration
public string themeName { get; }
Property Value
| Type | Description |
|---|---|
| string |
themeStyleSheet
A standalone theme file, assignable to PanelSettings.themeStyleSheet. Null when
the USS could not be compiled in this Unity version.
Declaration
public ThemeStyleSheet themeStyleSheet { get; }
Property Value
| Type | Description |
|---|---|
| ThemeStyleSheet |
tokenCount
How many tokens the theme defines.
Declaration
public int tokenCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
tokens
The theme's tokens: App UI tokens keyed without the --appui- prefix, and any other
custom property the theme carries under its full --name.
Declaration
public IReadOnlyDictionary<string, string> tokens { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, string> |
Remarks
Stored as two parallel lists because Unity cannot serialise a dictionary; rebuilt on demand rather than cached, since this is only for inspectors and tooling.