logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class SerenityUiPreviewWindow

    A preview of a view (a UnityMenuSettingsDefinition or a UnityCompositeViewDefinition) with two modes:

    • No theme — the structural wireframe (labeled boxes + option rows placed by view/option alignment).
    • A chosen theme — a LIVE render that instantiates that theme's real prefab templates into a hidden canvas and renders them to a texture, so the actual themed result is shown at a reference resolution.

    An optional backdrop image can sit behind the view (e.g. a gameplay screenshot) to judge it in context.

    Inheritance
    object
    SerenityUiPreviewWindow
    Namespace: Serenity.Ui.Infrastructure.Editor
    Assembly: Serenity.UnityUi.Infrastructure.Editor.dll
    Syntax
    public class SerenityUiPreviewWindow : EditorWindow

    Constructors

    SerenityUiPreviewWindow()

    Declaration
    public SerenityUiPreviewWindow()

    Properties

    CurrentDefinition

    The definition currently shown, including an unsaved scratch draft a wizard is previewing.

    Declaration
    public UnityViewDefinition CurrentDefinition { get; }
    Property Value
    Type Description
    UnityViewDefinition

    IsOpen

    Whether a preview window is currently open.

    Declaration
    public static bool IsOpen { get; }
    Property Value
    Type Description
    bool

    Methods

    CurrentDefinitionOfOpenWindow()

    The definition the first open preview window is showing, or null when none is open. Lets a wizard that pushes its own selection into the preview on every repaint first check whether the preview has navigated somewhere else on its own (e.g. a double-clicked TRANSITION option) before overwriting it.

    Declaration
    public static UnityViewDefinition CurrentDefinitionOfOpenWindow()
    Returns
    Type Description
    UnityViewDefinition

    CurrentThemeOfOpenWindow()

    The theme the first open preview window is drawing with, or null when none is open or the open window is on the structural wireframe. Lets a launcher display the window's own theme instead of keeping a second, competing copy of it.

    Declaration
    public static UnityUiThemeDefinition CurrentThemeOfOpenWindow()
    Returns
    Type Description
    UnityUiThemeDefinition

    MarkDirtyIfShowing(UnityViewDefinition)

    Marks every open window currently showing definition dirty and repaints it, without redirecting what it shows or touching its navigation state. A wizard calls this while the definition the window shows is being edited in place — an in-place edit to a scratch draft (title, options) raises no Unity change event the window's own polling would see, so nothing else would ever mark it dirty again. The window is the single owner of what it shows: this never assigns Serenity.Ui.Infrastructure.Editor.SerenityUiPreviewWindow._selected, it only requests a re-render of whatever is already there — a window showing something else (the author navigated the preview on its own) is left untouched. Safe to call every repaint: the per-window Serenity.Ui.Infrastructure.Editor.SerenityUiPreviewWindow._dirty check in Serenity.Ui.Infrastructure.Editor.SerenityUiPreviewWindow.RenderIfNeeded(System.Int32,System.Int32) already throttles the actual re-render to Serenity.Ui.Infrastructure.Editor.SerenityUiPreviewWindow.RenderInterval.

    Declaration
    public static void MarkDirtyIfShowing(UnityViewDefinition definition)
    Parameters
    Type Name Description
    UnityViewDefinition definition

    The definition being edited.

    Open()

    Declaration
    public static SerenityUiPreviewWindow Open()
    Returns
    Type Description
    SerenityUiPreviewWindow

    ReleaseTransitionResolver(PreviewTransitionResolver)

    Clears every open window's transition resolver if it is the one given. A wizard calls this from its own OnDisable so a closure over scratch objects the wizard is about to destroy never outlives the window.

    Declaration
    public static void ReleaseTransitionResolver(PreviewTransitionResolver resolver)
    Parameters
    Type Name Description
    PreviewTransitionResolver resolver

    The resolver instance to release; a window holding a different instance (including one still holding null) is left untouched.

    SetThemeOfOpenWindow(UnityUiThemeDefinition)

    Sets the theme on every open preview window and marks it as explicitly chosen, so no later seed can overwrite it. The toolbar's own theme popup routes through this.

    Declaration
    public static void SetThemeOfOpenWindow(UnityUiThemeDefinition theme)
    Parameters
    Type Name Description
    UnityUiThemeDefinition theme

    The theme to draw with; null switches to the structural wireframe.

    ShowFor(UnityViewDefinition, UnityUiThemeDefinition, PreviewTransitionResolver)

    Opens the window and points it at a definition — a Menu or Composite View, including an unsaved scratch instance.

    Declaration
    public static void ShowFor(UnityViewDefinition definition, UnityUiThemeDefinition theme, PreviewTransitionResolver transitionResolver = null)
    Parameters
    Type Name Description
    UnityViewDefinition definition

    The definition to show.

    UnityUiThemeDefinition theme

    A SEED for the theme, applied only while the window has never had a theme explicitly chosen — through its own toolbar popup or SetThemeOfOpenWindow(UnityUiThemeDefinition). The window is the single owner of its theme once opened; this seed exists only so a caller opening a fresh window can start it on a sane default instead of the wireframe. Pass null to apply no seed. Ignored entirely once a theme has been chosen — never overwrites the author's own pick, including an explicit "None (wireframe)".

    PreviewTransitionResolver transitionResolver

    Resolves a TRANSITION option's target for navigation; leave null to keep the window's own resolver (its toolbar-cache default, or one a wizard already injected).

    ThemeName(UnityUiThemeDefinition)

    Resolves a theme's display name, falling back to the asset's own object name when Name was left empty. Public so a launcher that shows the window's current theme (e.g. MenuPreviewLauncher) resolves the name the same way the window itself does, instead of duplicating this fallback.

    Declaration
    public static string ThemeName(UnityUiThemeDefinition theme)
    Parameters
    Type Name Description
    UnityUiThemeDefinition theme
    Returns
    Type Description
    string

    UpdateOpenWindow(UnityViewDefinition, PreviewTransitionResolver)

    Updates an already-open window without opening one — lets a wizard keep the preview in step with a scratch definition it is editing without the side effect of summoning a window the author closed on purpose. Carries no theme: the window owns its own theme once opened — see SetThemeOfOpenWindow(UnityUiThemeDefinition).

    Declaration
    public static void UpdateOpenWindow(UnityViewDefinition definition, PreviewTransitionResolver transitionResolver = null)
    Parameters
    Type Name Description
    UnityViewDefinition definition

    The definition being edited.

    PreviewTransitionResolver transitionResolver

    Resolves a TRANSITION option's target for navigation; leave null to keep the window's own resolver.

    UpdateOpenWindow(UnityViewDefinition, UnityUiThemeDefinition, PreviewTransitionResolver)

    Shipped public API kept for one release after the theme parameter was removed — see the Serenity versioning convention (middle digit bumps on a breaking change). Forwards the theme to SetThemeOfOpenWindow(UnityUiThemeDefinition) and the rest to UpdateOpenWindow(UnityViewDefinition, PreviewTransitionResolver).

    Declaration
    [Obsolete("The preview owns its theme; use SetThemeOfOpenWindow or UpdateOpenWindow(definition, resolver).")]
    public static void UpdateOpenWindow(UnityViewDefinition definition, UnityUiThemeDefinition theme, PreviewTransitionResolver transitionResolver = null)
    Parameters
    Type Name Description
    UnityViewDefinition definition
    UnityUiThemeDefinition theme
    PreviewTransitionResolver transitionResolver
    In this article
    © 2026 Serenity. All Rights Reserved