Class ScyllaEditorBase
Base class for Scylla custom inspectors built with UI Toolkit.
Inheritance
Inherited Members
Namespace: Scylla.Core.Editor
Assembly: ScyllaCore.Editor.dll
Syntax
public abstract class ScyllaEditorBase : Editor
Remarks
Subclasses override CreateInspectorGUI() returning a UnityEngine.UIElements.VisualElement tree. Do NOT override UnityEditor.Editor.OnInspectorGUI() on a UI Toolkit subclass; the framework rule is: all new editor UI is UI Toolkit.
The base class auto-loads ScyllaCommon.uss and the appropriate
dark/light theme variant on the returned root via the same loader
ScyllaToolWindowBase uses, so all Scylla inspectors and
windows share one stylesheet stack and one theme switch.
Helpers are provided for the most common authoring patterns: headers, sections, foldouts, help boxes, horizontal lines, buttons, property fields, and validation reports. All helpers return UnityEngine.UIElements.VisualElement instances rather than drawing immediately.
Foldout state: persisted via UnityEditor.EditorPrefs keyed by a stable identifier (asset path or instance ID). Fold state survives play-mode entry, domain reload, and Unity restart.
Properties
ShowPropertyDescriptions
Gets whether inspectors should display property descriptions as muted labels above each field. Reads from UnityEditor.EditorPrefs using the PREFS_INLINE_EDITOR_DESCRIPTIONS key. Toggled via the Scylla Editor menu.
Declaration
protected static bool ShowPropertyDescriptions { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
AddDescribedChildFields(VisualElement, SerializedProperty)
Iterates the visible child properties of parentProperty and adds
a description-aware property field for each to container. Use
this for nested settings structs whose individual fields each carry their own
[Tooltip] attributes. Skips silently when parentProperty
is null.
Declaration
protected void AddDescribedChildFields(VisualElement container, SerializedProperty parentProperty)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | container | The container to add fields to. |
| SerializedProperty | parentProperty | The parent serialized property whose visible children should be drawn inline (without the parent's own foldout label). |
AddDescribedField(VisualElement, SerializedProperty, string)
Adds a property field with its tooltip rendered as an inline muted description
above the field. Skips silently if property is null so
subclasses can call this defensively without per-property null checks.
Declaration
protected void AddDescribedField(VisualElement container, SerializedProperty property, string label = null)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | container | The container to add the property field to. |
| SerializedProperty | property | The serialized property. |
| string | label | Optional label override; |
AddSubSectionHeader(VisualElement, string, bool)
Adds a sub-section header label to container. Uses the
scylla-section-header USS class so the header carries the framework's
standard size and weight. The first sub-section sits flush against the
container top; subsequent sub-sections receive a top margin so they read as
visually distinct groups.
Declaration
protected void AddSubSectionHeader(VisualElement container, string title, bool isFirst = false)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | container | The container to add the header to. |
| string | title | The header text. |
| bool | isFirst | Whether this is the first sub-section. Pass |
BuildButton(string, Action)
Builds a labelled UnityEngine.UIElements.Button wired to onClick.
Declaration
protected Button BuildButton(string label, Action onClick)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | Button label. |
| Action | onClick | Click handler. |
Returns
| Type | Description |
|---|---|
| Button |
BuildButtonRow(string[], Action[])
Builds a horizontal row of buttons. Each button calls the corresponding entry in
callbacks when clicked.
Declaration
protected static VisualElement BuildButtonRow(string[] labels, Action[] callbacks)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | labels | Button label strings. |
| Action[] | callbacks | Click callbacks; must have the same length as |
Returns
| Type | Description |
|---|---|
| VisualElement |
BuildEditModeOnlyContainer()
Builds a UnityEngine.UIElements.VisualElement container that is visible only while the Unity Editor is in Edit mode and hides itself while Play mode is active. The inverse of BuildRuntimeContainer(); use this for actions or hints that only make sense outside of a running game (e.g. authoring buttons that mutate serialized state). Subscribes to UnityEditor.EditorApplication.playModeStateChanged on attach and unsubscribes on detach via a single registration so the container does not leak handlers.
Declaration
protected static VisualElement BuildEditModeOnlyContainer()
Returns
| Type | Description |
|---|---|
| VisualElement | A new UnityEngine.UIElements.VisualElement already wired with edit-mode-only visibility logic; append children to it and add it to the inspector tree. |
BuildExportConfigFileButton(ScyllaConfiguration)
Builds an "Export Config File" button wired to the supplied configuration.
Clicking the button shows a dropdown with export location options (User Documents
or App Folder). Returns null when configuration is
null.
Declaration
protected static Button BuildExportConfigFileButton(ScyllaConfiguration configuration)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaConfiguration | configuration | The configuration asset to export. |
Returns
| Type | Description |
|---|---|
| Button |
BuildFoldout(string, string, bool)
Builds a UnityEngine.UIElements.Foldout whose expanded state persists across domain reloads via UnityEditor.EditorPrefs. Add child content to the returned foldout.
Declaration
protected Foldout BuildFoldout(string title, string persistKey, bool defaultExpanded = true)
Parameters
| Type | Name | Description |
|---|---|---|
| string | title | The foldout title. |
| string | persistKey | Stable key for persistence (e.g. record ID + section name). |
| bool | defaultExpanded | Initial expanded state when no preference is stored. |
Returns
| Type | Description |
|---|---|
| Foldout | The foldout. Add children via |
BuildHeader(string, string)
Builds a styled header label suitable for the top of an inspector. Optional subtitle renders muted underneath.
Declaration
protected VisualElement BuildHeader(string title, string subtitle = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | title | The header text. |
| string | subtitle | Optional subtitle text. |
Returns
| Type | Description |
|---|---|
| VisualElement | A UnityEngine.UIElements.VisualElement containing the header. |
BuildHelpBox(string, HelpBoxMessageType)
Builds a UI Toolkit UnityEngine.UIElements.HelpBox with the supplied message and severity.
Declaration
protected HelpBox BuildHelpBox(string message, HelpBoxMessageType type = HelpBoxMessageType.Info)
Parameters
| Type | Name | Description |
|---|---|---|
| string | message | The message text. |
| HelpBoxMessageType | type | The severity level. |
Returns
| Type | Description |
|---|---|
| HelpBox |
BuildHighlightedBox()
Builds a container with a subtle accent-tinted background for grouping properties inside configuration foldout sections.
Declaration
protected static VisualElement BuildHighlightedBox()
Returns
| Type | Description |
|---|---|
| VisualElement |
BuildHighlightedFoldout(string, string, bool)
Builds a UnityEngine.UIElements.Foldout with an accent border-left stripe and tinted background, intended for configuration property sections. State persists via UnityEditor.EditorPrefs.
Declaration
protected Foldout BuildHighlightedFoldout(string title, string persistKey, bool defaultExpanded = true)
Parameters
| Type | Name | Description |
|---|---|---|
| string | title | Foldout title. |
| string | persistKey | Stable key for EditorPrefs persistence. |
| bool | defaultExpanded | Default expanded state when no preference is stored. |
Returns
| Type | Description |
|---|---|
| Foldout |
BuildHorizontalLine()
Builds a horizontal separator line. Width fills the parent.
Declaration
protected VisualElement BuildHorizontalLine()
Returns
| Type | Description |
|---|---|
| VisualElement |
BuildInspector(VisualElement)
Subclasses populate root with their inspector content.
The root has the shared Scylla stylesheets pre-loaded.
Declaration
protected abstract void BuildInspector(VisualElement root)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | root | The inspector's root element. |
BuildLabelValue(string, string)
Builds a two-column label-value row. The left column shows the descriptive label and the right column shows the value in bold.
Declaration
protected static VisualElement BuildLabelValue(string label, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | Descriptive label text. |
| string | value | Value text shown in bold. |
Returns
| Type | Description |
|---|---|
| VisualElement |
BuildLabelValueColored(string, string, Color)
Builds a two-column label-value row where the value label is tinted with the supplied color. Use this to convey status (e.g. green for success, red for error).
Declaration
protected static VisualElement BuildLabelValueColored(string label, string value, Color valueColor)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | Descriptive label text. |
| string | value | Value text shown in bold. |
| Color | valueColor | Color applied to the value label. |
Returns
| Type | Description |
|---|---|
| VisualElement |
BuildPropertyField(SerializedProperty, string)
Builds a UnityEditor.UIElements.PropertyField for the supplied serialized property.
Custom UnityEditor.PropertyDrawer instances with
CreatePropertyGUI overrides are honoured automatically.
Declaration
protected PropertyField BuildPropertyField(SerializedProperty property, string label = null)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializedProperty | property | The serialized property. |
| string | label | Optional label override; |
Returns
| Type | Description |
|---|---|
| PropertyField |
BuildPropertyFieldWithDescription(SerializedProperty, string)
Builds a container holding an optional muted description label (sourced from the property's tooltip attribute) followed by a UnityEditor.UIElements.PropertyField. The description label is only shown when ShowPropertyDescriptions is enabled and the tooltip is non-empty.
Declaration
protected VisualElement BuildPropertyFieldWithDescription(SerializedProperty property, string label = null)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializedProperty | property | The serialized property. |
| string | label | Optional label override; |
Returns
| Type | Description |
|---|---|
| VisualElement | A container UnityEngine.UIElements.VisualElement that wraps the description label (when shown) and the property field. Includes a bottom margin so consecutive properties are visually separated. |
BuildRuntimeContainer()
Builds a UnityEngine.UIElements.VisualElement container that is visible only while the Unity Editor is in Play mode and hides itself otherwise. Add runtime-state content as children of the returned element, then schedule updates via RecurringSafe(VisualElement, Action, long).
Declaration
protected static VisualElement BuildRuntimeContainer()
Returns
| Type | Description |
|---|---|
| VisualElement |
BuildSection(string)
Builds a styled section box with a header label. Add child content to the returned element.
Declaration
protected VisualElement BuildSection(string title)
Parameters
| Type | Name | Description |
|---|---|---|
| string | title | The section title. |
Returns
| Type | Description |
|---|---|
| VisualElement | A UnityEngine.UIElements.VisualElement with section-box styling. Add children to it. |
BuildSectionFoldout(string, string, bool)
Builds a UnityEngine.UIElements.Foldout with an accent-tinted, bold title intended for top-level configuration sections such as "Config Files", "Validation", "Metadata", and "Actions". Mirrors the IMGUI baseline that distinguished these section headers from regular property foldouts. State persists via UnityEditor.EditorPrefs.
Declaration
protected Foldout BuildSectionFoldout(string title, string persistKey, bool defaultExpanded = true)
Parameters
| Type | Name | Description |
|---|---|---|
| string | title | Foldout title. |
| string | persistKey | Stable key for EditorPrefs persistence. |
| bool | defaultExpanded | Default expanded state when no preference is stored. |
Returns
| Type | Description |
|---|---|
| Foldout |
CountValidationIssues(ConfigurationValidationResult[])
Counts errors and warnings in an array of ConfigurationValidationResult objects.
Declaration
protected static (int errors, int warnings) CountValidationIssues(ConfigurationValidationResult[] results)
Parameters
| Type | Name | Description |
|---|---|---|
| ConfigurationValidationResult[] | results | The validation results array. Returns |
Returns
| Type | Description |
|---|---|
| (int errors, int warnings) | Tuple of |
CreateInspectorGUI()
Creates the UI Toolkit inspector root. Loads the shared Scylla stylesheets onto the root element, installs the live theme watcher so dark/light switching updates open inspectors without requiring them to be closed, then delegates content construction to BuildInspector(VisualElement).
Declaration
public override VisualElement CreateInspectorGUI()
Returns
| Type | Description |
|---|---|
| VisualElement | The root UnityEngine.UIElements.VisualElement for this inspector, already populated with the shared stylesheets and the subclass's inspector content. |
Overrides
GetValidationHeaderLabel(int, int)
Generates a human-readable foldout header label that summarizes the validation result. Examples: "Validation (2 Errors)", "Validation (1 Warning)", "Validation (Valid)".
Declaration
protected static string GetValidationHeaderLabel(int errorCount, int warningCount)
Parameters
| Type | Name | Description |
|---|---|---|
| int | errorCount | |
| int | warningCount |
Returns
| Type | Description |
|---|---|
| string |
Pluralize(string, int)
Returns the singular or plural form of singular based on
count. Uses simple English 's' appending - sufficient for
invariant strings used in the Scylla editor.
Declaration
protected static string Pluralize(string singular, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| string | singular | |
| int | count |
Returns
| Type | Description |
|---|---|
| string |