Class ScyllaScheduler
Editor-facing UI Toolkit scheduler helpers that pair every recurring or
debounced scheduled item with an automatic UnityEngine.UIElements.DetachFromPanelEvent
cancellation. Use these in place of raw
host.schedule.Execute(...).Every(...) / .StartingIn(...) to
avoid stale-reference callbacks after the hosting inspector or window tears
down.
Inherited Members
Namespace: Scylla.Core.Editor
Assembly: ScyllaCore.Editor.dll
Syntax
public static class ScyllaScheduler
Remarks
The behavior lives in ScyllaSafeScheduler, which serves runtime panels as well. This wrapper exists so editor code reports a failing callback under Editor rather than UI, and so the editor-specific hazard below stays documented where editor authors will read it.
Scheduled items registered via UI Toolkit's UnityEngine.UIElements.VisualElement.schedule
keep firing until they are explicitly paused, or until the panel they
live on is destroyed. Between an inspector teardown and the next
UnityEngine.UIElements.DetachFromPanelEvent, captured UnityEditor.SerializedProperty
instances may already be disposed. Reading from a disposed property
throws InvalidOperationException inside the scheduled callback.
Pausing on detach prevents that window.
The framework convention (per code-style.md UI Toolkit Mandate)
is to use these helpers for any new recurring or debounced scheduled
item. Direct host.schedule.Execute(...).Every(...) without a
matching DetachFromPanelEvent Pause is rejected at code review.
Methods
DebouncedSafe(VisualElement, Action, long)
Creates a one-shot debounced scheduled item that fires
callback after delayMs
milliseconds, and pauses automatically on
UnityEngine.UIElements.DetachFromPanelEvent. Pause the returned item and call
ExecuteLater(long) on it to reset
the debounce window without allocating a fresh scheduler entry.
Declaration
public static IVisualElementScheduledItem DebouncedSafe(VisualElement host, Action callback, long delayMs)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | host | The visual element whose panel attachment controls the lifetime of the
scheduled item. Must not be |
| Action | callback | The action to invoke after the delay. Must not be |
| long | delayMs | The initial delay in milliseconds before the first fire. |
Returns
| Type | Description |
|---|---|
| IVisualElementScheduledItem | The created UnityEngine.UIElements.IVisualElementScheduledItem, already scheduled. Call
|
Remarks
Typical debounce pattern when responding to a text field's value-changed event:
var debounce = ScyllaScheduler.DebouncedSafe(root, OnSearchChanged, 300);
searchField.RegisterValueChangedCallback(evt =>
{
debounce.Pause();
debounce.ExecuteLater(300);
});
This reuses the single allocated scheduler entry across every keystroke, avoiding per-keystroke allocations.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
OnceSafe(VisualElement, Action)
Creates a scheduled item that fires callback once on
the next scheduler pass, and pauses automatically on
UnityEngine.UIElements.DetachFromPanelEvent.
Declaration
public static IVisualElementScheduledItem OnceSafe(VisualElement host, Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | host | The visual element whose panel attachment controls the lifetime of the
scheduled item. Must not be |
| Action | callback | The action to invoke once. Must not be |
Returns
| Type | Description |
|---|---|
| IVisualElementScheduledItem | The created UnityEngine.UIElements.IVisualElementScheduledItem. |
Remarks
Use this to coalesce a burst of changes into a single piece of work, such as rebuilding an inspector section once after several properties are written rather than once per property.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
RecurringSafe(VisualElement, Action, long)
Creates a recurring scheduled item that fires callback
every intervalMs milliseconds while
host is attached to a panel, and pauses automatically
on UnityEngine.UIElements.DetachFromPanelEvent.
Declaration
public static IVisualElementScheduledItem RecurringSafe(VisualElement host, Action callback, long intervalMs)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | host | The visual element whose panel attachment controls the lifetime of the
scheduled item. Must not be |
| Action | callback | The action to invoke on every tick. Must not be |
| long | intervalMs | The tick interval in milliseconds. |
Returns
| Type | Description |
|---|---|
| IVisualElementScheduledItem | The created UnityEngine.UIElements.IVisualElementScheduledItem. Keep the reference if you need to pause the item manually before the host detaches. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |