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.
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
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. |
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 |
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. |
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.
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 |