Class ScyllaWizardWindowBase
Base class for Scylla wizard windows built with UI Toolkit.
Inheritance
Inherited Members
Namespace: Scylla.Core.Editor
Assembly: ScyllaCore.Editor.dll
Syntax
public abstract class ScyllaWizardWindowBase : ScyllaToolWindowBase
Remarks
Provides a full wizard infrastructure: step management, navigation (back/next/finish/cancel), validation gates, step content rendering, and state persistence via UnityEditor.SessionState.
Two layout modes are supported:
- TopBar - horizontal step indicator at the top, suitable for wizards with fewer than 7 steps.
- Sidebar - vertical step list on the left, suitable for wizards with 7 or more steps.
Subclasses must implement DefineSteps() to provide step definitions, and BuildStepContent(int, VisualElement) to populate each step's content area. Override ValidateStep(int) to add validation gates before step advancement.
Fields
CARD_SPACING
Space between cards, and below the page introduction.
Declaration
protected const float CARD_SPACING = 10
Field Value
| Type | Description |
|---|---|
| float |
FIELD_SPACING
Space between fields inside a card, and between a card's title and its first field.
Declaration
protected const float FIELD_SPACING = 6
Field Value
| Type | Description |
|---|---|
| float |
Properties
CurrentStepIndex
Zero-based index of the current visible step.
Declaration
protected int CurrentStepIndex { get; }
Property Value
| Type | Description |
|---|---|
| int |
IsFirstStep
Whether the wizard is on the first visible step.
Declaration
protected bool IsFirstStep { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsLastStep
Whether the wizard is on the last visible step.
Declaration
protected bool IsLastStep { get; }
Property Value
| Type | Description |
|---|---|
| bool |
LockNavigationOnLastStep
Whether Cancel and Back should be hidden on the wizard's last step. Default
is true, appropriate for wizards whose last step is a post-completion
status page (e.g. the Setup Wizard's "Complete" step). Wizards whose final step
is a pre-action review where the user might still want to revise or cancel
should override this to return false.
Declaration
protected virtual bool LockNavigationOnLastStep { get; }
Property Value
| Type | Description |
|---|---|
| bool |
TotalSteps
Total number of defined steps (including hidden ones).
Declaration
protected int TotalSteps { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
AddCard(VisualElement, string)
Adds a framed card with a title, to group related fields on a page.
Declaration
protected static VisualElement AddCard(VisualElement container, string title)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | container | The element to add the card to. |
| string | title | The card's title. |
Returns
| Type | Description |
|---|---|
| VisualElement | The card, to add fields to. |
AddPageIntro(VisualElement, string, Action, string, string, string)
Adds the standard top of a module wizard page: the title with an optional Reset to Defaults button, a short subtitle naming the task, a paragraph that explains the page's subject to someone new to it, and an info box that says what to do on the page.
Declaration
protected static void AddPageIntro(VisualElement root, string title, Action onReset, string subtitle, string body, string instruction)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | root | The page. |
| string | title | The page title. |
| Action | onReset | Returns the page to its default values, or null for no Reset to Defaults button. |
| string | subtitle | The task, in a few words. |
| string | body | What the page is about and why it matters. |
| string | instruction | What to do on the page. |
AddProblemBox(VisualElement)
Adds an empty warning box for a page's problem, to fill with ShowProblem(HelpBox, string).
Declaration
protected static HelpBox AddProblemBox(VisualElement root)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | root | The page. |
Returns
| Type | Description |
|---|---|
| HelpBox | The warning box. |
ApplySectionBoxStyles(VisualElement)
Applies the .scylla-section-box class plus inline-style fallback values
(border, background, padding, margin) so the visual frame renders reliably
even when USS rule resolution fails. Inline styles match what the USS rule
would set, so they are idempotent when the rule applies normally.
Declaration
protected static void ApplySectionBoxStyles(VisualElement element)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | element | The element to convert into a section-box card. |
BuildFlushHelpBox(string, HelpBoxMessageType)
Builds a help box without side margins, so its edges line up with the cards on a page.
Declaration
protected static HelpBox BuildFlushHelpBox(string message, HelpBoxMessageType type)
Parameters
| Type | Name | Description |
|---|---|---|
| string | message | The message. |
| HelpBoxMessageType | type | The severity, which picks the icon. |
Returns
| Type | Description |
|---|---|
| HelpBox | The help box. |
BuildHint(string)
Builds a short line of small muted text, to place under a field.
Declaration
protected static Label BuildHint(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The hint. |
Returns
| Type | Description |
|---|---|
| Label | The hint label. |
BuildStepBody(string)
Builds a regular-color body paragraph for use after the step description and before the help banner. Use this for multi-sentence explanatory text. The label wraps automatically and reads at the editor's primary text color.
Declaration
protected static Label BuildStepBody(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text |
Returns
| Type | Description |
|---|---|
| Label |
BuildStepContent(int, VisualElement)
Builds the content for the step at the given index.
Add children to stepRoot.
Declaration
protected abstract void BuildStepContent(int stepIndex, VisualElement stepRoot)
Parameters
| Type | Name | Description |
|---|---|---|
| int | stepIndex | Zero-based step index. |
| VisualElement | stepRoot | The container to add step content to. |
BuildStepDescription(string)
Builds a muted single-line subtitle for use immediately below the step header. Use this for the short genre/category descriptor that summarises the step.
Declaration
protected static Label BuildStepDescription(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text |
Returns
| Type | Description |
|---|---|
| Label |
BuildStepHeader(string)
Builds a large bold page-title label for use at the top of a step body.
Declaration
protected static Label BuildStepHeader(string title)
Parameters
| Type | Name | Description |
|---|---|---|
| string | title |
Returns
| Type | Description |
|---|---|
| Label |
CenterOnMainWindow(EditorWindow, Vector2)
Places a wizard window in the middle of the Unity main window. The size is kept within the main window and never goes below the window's minimum size.
Declaration
protected static void CenterOnMainWindow(EditorWindow window, Vector2 size)
Parameters
| Type | Name | Description |
|---|---|---|
| EditorWindow | window | The wizard window. |
| Vector2 | size | The size to give it. |
DefineSteps()
Defines the wizard steps. Called once during window creation. Return an array of ScyllaWizardWindowBase.WizardStepDef instances.
Declaration
protected abstract ScyllaWizardWindowBase.WizardStepDef[] DefineSteps()
Returns
| Type | Description |
|---|---|
| WizardStepDef[] |
GetBackLabel()
Back button label. Default: "Back".
Declaration
protected virtual string GetBackLabel()
Returns
| Type | Description |
|---|---|
| string |
GetCancelLabel()
Cancel button label. Default: "Cancel".
Declaration
protected virtual string GetCancelLabel()
Returns
| Type | Description |
|---|---|
| string |
GetFinishLabel()
Finish button label. Default: "Finish".
Declaration
protected virtual string GetFinishLabel()
Returns
| Type | Description |
|---|---|
| string |
GetLayout()
Returns the layout mode. Default: TopBar.
Declaration
protected virtual ScyllaWizardWindowBase.WizardLayout GetLayout()
Returns
| Type | Description |
|---|---|
| ScyllaWizardWindowBase.WizardLayout |
GetNextLabel()
Next button label. Default: "Next".
Declaration
protected virtual string GetNextLabel()
Returns
| Type | Description |
|---|---|
| string |
GetSessionKey()
Returns the session state key prefix for step persistence.
Declaration
protected virtual string GetSessionKey()
Returns
| Type | Description |
|---|---|
| string |
GetSidebarWidth()
Returns the sidebar width in pixels. Default: 180.
Declaration
protected virtual float GetSidebarWidth()
Returns
| Type | Description |
|---|---|
| float |
GoToNextStep()
Advances to the next visible step if validation passes.
Declaration
protected void GoToNextStep()
GoToPreviousStep()
Goes back to the previous visible step.
Declaration
protected void GoToPreviousStep()
GoToStep(int)
Navigates directly to the step at stepIndex.
Declaration
protected void GoToStep(int stepIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | stepIndex | Zero-based step index. |
Remarks
A no-op before the steps exist, for the same reason as
SetStepVisible(int, bool), and a no-op for a step that is currently hidden.
The visibility guard matches GoToNextStep and GoToPreviousStep,
which can only ever land on a visible step by construction. Without it a caller
could jump to a step the indicator does not list, leaving the wizard showing a
step with no entry in its own sidebar.
OnCreateGUI()
Called by CreateGUI() after the shared layout shell (toolbar, content container, status bar) is ready. Invokes DefineSteps() to build the step list, restores the last step from UnityEditor.SessionState (clamped to valid range), then builds the chosen layout and displays the current step. Sealed: subclasses must not override this method; use BuildStepContent(int, VisualElement) to inject per-step UI.
Declaration
protected override sealed void OnCreateGUI()
Overrides
OnResetWizardSession()
Override in subclasses to clear per-session private state (caches, selections, toggle defaults) when the user reopens the wizard. The base implementation is a no-op. Called from ResetWizardSessionState<T>() on the existing window instance, if any.
Declaration
protected virtual void OnResetWizardSession()
OnStepChanged(int)
Called when the current step index changes.
Declaration
protected virtual void OnStepChanged(int newIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | newIndex | The new step index. |
OnStepCompleted(int)
Called after validation passes when advancing from a step.
Declaration
protected virtual void OnStepCompleted(int stepIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | stepIndex | The completed step index. |
OnWindowDestroyed()
Called when the editor window is destroyed (closed by the user, or programmatically
via UnityEditor.EditorWindow.Close()). Subclasses override to release resources or
clear persistent state. The base implementation is empty. Note that domain reload
triggers OnDisable but not OnDestroy; this hook fires only on actual
window destruction.
Declaration
protected override void OnWindowDestroyed()
Overrides
OnWizardCancelled()
Called when the wizard is cancelled.
Declaration
protected virtual void OnWizardCancelled()
OnWizardFinished()
Called when the wizard is finished (Finish button clicked and last step validated).
Declaration
protected virtual void OnWizardFinished()
RefreshCurrentStepContent()
Rebuilds the current step's content area without re-running OnStepChanged(int) or any detection / validation hooks. Use this when a subclass needs to re-render the current step's UI in place because state that drives the layout changed (e.g. the Setup Wizard's "Create New Configuration Instead" button switching from existing-configuration UI to new-configuration UI).
Declaration
protected void RefreshCurrentStepContent()
RefreshNavigationState()
Re-runs ValidateStep(int) for the current step and updates the Next / Finish button enabled state accordingly. Subclasses call this when state that affects validation changes mid-step (e.g. a text field becomes non-empty, or external scene state changes a precondition).
Declaration
protected void RefreshNavigationState()
ResetWizardSessionState<T>()
Clears the persisted step / highest-reached indices for a wizard subclass before
the window is opened. Wizard subclasses should call this from their static
ShowWizard method so every explicit menu invocation starts fresh at step
one, regardless of any stale state left behind by an earlier session that did
not exit cleanly.
Declaration
protected static void ResetWizardSessionState<T>() where T : ScyllaWizardWindowBase
Type Parameters
| Name | Description |
|---|---|
| T | The concrete wizard subclass. |
SetShown(VisualElement, bool)
Shows or hides an element without removing it from the page.
Declaration
protected static void SetShown(VisualElement element, bool shown)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | element | The element. |
| bool | shown | Whether the element is shown. |
SetStepVisible(int, bool)
Marks the step at stepIndex as visible or hidden.
Declaration
protected void SetStepVisible(int stepIndex, bool visible)
Parameters
| Type | Name | Description |
|---|---|---|
| int | stepIndex | Zero-based step index. |
| bool | visible | Whether the step is shown. |
Remarks
A no-op before the steps exist. They are built in OnCreateGUI, which Unity
runs when the window is shown or docked, so a subclass that decides step
visibility from state it already has can reach this first and would otherwise
throw rather than simply having nothing to hide yet.
ShouldCloseAfterFinish()
Whether Finish closes the wizard, asked after OnStepCompleted(int) ran for the
last step. Return false when the work done there failed, so the wizard stays open
with every answer intact. Default: true.
Declaration
protected virtual bool ShouldCloseAfterFinish()
Returns
| Type | Description |
|---|---|
| bool |
ShowProblem(HelpBox, string)
Shows a problem in a help box, or hides the box when there is none.
Declaration
protected static void ShowProblem(HelpBox box, string problem)
Parameters
| Type | Name | Description |
|---|---|---|
| HelpBox | box | The help box. |
| string | problem | The problem, or null. |
ValidateStep(int)
Validates the current step before advancing. Return true to allow advancing,
false to block. Default implementation always allows.
Declaration
protected virtual bool ValidateStep(int stepIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | stepIndex | The step being validated. |
Returns
| Type | Description |
|---|---|
| bool |