Class HudPreviewWindow
A dockable window showing the HUD as it will be drawn, at a chosen resolution and theme — and letting an author select, move, scale and rotate its elements directly, Photoshop-style.
Namespace: Serenity.GameUi.Infrastructure.Editor.Builder
Assembly: Serenity.UnityGameUi.Infrastructure.Editor.dll
Syntax
public sealed class HudPreviewWindow : EditorWindow
Remarks
Separate from the builder rather than embedded in it because the two want opposite things from the space: the builder is a tall scrolling form, while a HUD is a wide frame that only reads at size. Given its own window it can be docked, floated over the game view, or pulled to a second monitor, and resizing it costs the form nothing.
It follows whatever the builder is editing, including unsaved edits, and falls back to a HUD asset picked here so it is also useful on its own. Selection flows both ways with the builder through Interacted and the optional index on UpdateOpenWindow(UnityHudDefinition, UnityUiThemeDefinition, int), but neither window needs to know the other exists — a standalone preview simply has nobody listening.
Constructors
HudPreviewWindow()
Declaration
public HudPreviewWindow()
Properties
IsOpen
Whether a preview window is currently open.
Declaration
public static bool IsOpen { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
Invalidate()
Forces the next paint to re-render.
Declaration
public void Invalidate()
ShowFor(UnityHudDefinition, UnityUiThemeDefinition, int)
Opens the window and points it at a HUD.
Declaration
public static void ShowFor(UnityHudDefinition hud, UnityUiThemeDefinition theme, int selectedElementIndex = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityHudDefinition | hud | The HUD to show; may be an unsaved scratch instance. |
| UnityUiThemeDefinition | theme | The theme to draw with. |
| int | selectedElementIndex | Element to select on open, or -1 to leave the selection as it is. |
ShowWindow()
Declaration
public static void ShowWindow()
UpdateOpenWindow(UnityHudDefinition, UnityUiThemeDefinition, int)
Updates an already-open window without opening one.
Declaration
public static void UpdateOpenWindow(UnityHudDefinition hud, UnityUiThemeDefinition theme, int selectedElementIndex = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityHudDefinition | hud | The HUD being edited. |
| UnityUiThemeDefinition | theme | The theme to draw with, or null to leave the window's own choice alone. |
| int | selectedElementIndex | Element the wizard has selected, or -1 to leave the preview's own selection alone. |
Remarks
Lets the builder keep the preview in step every pass without the side effect of summoning a window the author closed on purpose.
Events
Interacted
Raised whenever an element is selected or transformed by direct manipulation in the preview.
Declaration
public static event Action<PreviewInteraction> Interacted
Event Type
| Type | Description |
|---|---|
| Action<PreviewInteraction> |