Class PreviewToolbarAssetCache
The View Preview toolbar's definition/theme dropdown lists, rebuilt only when the project changes —
OnInspectorUpdate repaints continuously, so loading every definition and theme on every frame
would hammer the AssetDatabase (and re-trigger any pending script-reference fix those loads surface,
reload after reload). Extracted from SerenityUiPreviewWindow to keep that file under its
own size ratchet; owns its own UnityEditor.EditorApplication.projectChanged subscription so the window
only has to construct one on open and Dispose() it on close.
Inherited Members
Namespace: Serenity.Ui.Infrastructure.Editor.Preview
Assembly: Serenity.UnityUi.Infrastructure.Editor.dll
Syntax
public sealed class PreviewToolbarAssetCache
Constructors
PreviewToolbarAssetCache()
Declaration
public PreviewToolbarAssetCache()
Properties
DefinitionNames
Each definition's toolbar label ("<ViewKindLabel>/<DefName>"), parallel to Definitions.
Declaration
public IReadOnlyList<string> DefinitionNames { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<string> |
Definitions
Every previewable definition in the project, grouped by view kind (see EnsureFresh()).
Declaration
public IReadOnlyList<UnityViewDefinition> Definitions { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<UnityViewDefinition> |
Themes
Every theme in the project.
Declaration
public IReadOnlyList<UnityUiThemeDefinition> Themes { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<UnityUiThemeDefinition> |
Methods
Dispose()
Unsubscribes from UnityEditor.EditorApplication.projectChanged. Call from the owning window's OnDisable.
Declaration
public void Dispose()
EnsureFresh()
Rebuilds the cached lists if they were discarded; a no-op otherwise.
Declaration
public void EnsureFresh()
IndexOfDefinition(UnityViewDefinition)
The index definition occupies in Definitions, or -1.
Declaration
public int IndexOfDefinition(UnityViewDefinition definition)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityViewDefinition | definition |
Returns
| Type | Description |
|---|---|
| int |
IndexOfTheme(UnityUiThemeDefinition)
The index theme occupies in Themes, or -1.
Declaration
public int IndexOfTheme(UnityUiThemeDefinition theme)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityUiThemeDefinition | theme |
Returns
| Type | Description |
|---|---|
| int |
Invalidate()
Discards the cached lists, forcing the next EnsureFresh() to reload them.
Declaration
public void Invalidate()
TryResolveById(string, out UnityViewDefinition)
Resolves a definition by its stored Id, refreshing the cache first if needed.
Declaration
public bool TryResolveById(string targetViewId, out UnityViewDefinition resolved)
Parameters
| Type | Name | Description |
|---|---|---|
| string | targetViewId | The id to look up. |
| UnityViewDefinition | resolved | The matching definition, when found. |
Returns
| Type | Description |
|---|---|
| bool | True when a definition with that id is in the project. |