Class ProceduralAnimatorSimulator
Drives a live ProceduralAnimatorComponent pipeline against a hidden preview instance of a
model, so the Animation Hub can play, scrub and poke at a profile's rules/layers/actions without ever
entering Play mode or touching the user's scene. Owns a Serenity.Global.Infrastructure.Editor.Preview.SerenityModelPreviewSession (the
hidden instance) and an Serenity.Global.Infrastructure.Editor.Preview.EditorPlaybackClock (the simulated time source); every write this
class makes lands on Serenity.Global.Infrastructure.Editor.Preview.SerenityModelPreviewSession.InstanceRoot or its own transient
dictionaries — nothing is serialized, nothing is dirtied, and no asset is ever touched.
Inheritance
ProceduralAnimatorSimulator
Assembly: Serenity.AnimationHub.Editor.dll
Syntax
public sealed class ProceduralAnimatorSimulator : IDisposable
Constructors
ProceduralAnimatorSimulator(Action)
Declaration
public ProceduralAnimatorSimulator(Action repaintRequested)
Parameters
| Type |
Name |
Description |
| Action |
repaintRequested |
|
Fields
DefaultPulseDurationSeconds
Duration of a "Pulse" button replay — matches the traversal-length pulses gameplay
controllers like RailShooter's EnemyBehaviorController write onto their state keys.
Declaration
public const float DefaultPulseDurationSeconds = 1.2
Field Value
Properties
IsBound
Declaration
public bool IsBound { get; }
Property Value
IsPlaying
Declaration
public bool IsPlaying { get; }
Property Value
Session
Declaration
public SerenityModelPreviewSession Session { get; }
Property Value
| Type |
Description |
| SerenityModelPreviewSession |
The owned preview session, or null before the first successful Bind(GameObject).
|
SimulatedTime
Declaration
public float SimulatedTime { get; }
Property Value
StateKeys
Declaration
public IReadOnlyList<ProceduralStateKeyBinding> StateKeys { get; }
Property Value
StatusText
Declaration
public string StatusText { get; }
Property Value
Methods
AdvancePulses(float)
Writes every active pulse's current value onto its state key, at time, so
the slider visually tracks the replayed arc; a pulse that has finished writes its binding's
MinValue (gameplay pulses always end back at zero) and is
removed. Runs at the top of every internal tick so it stays in lockstep with whatever advances
SimulatedTime — the playing clock, a paused StepOnce(), or a paused
SetStateValue(UnityStateKey, float) re-tick. Public so tests can drive pulse advancement directly without
pumping EditorApplication.update.
Declaration
public void AdvancePulses(float time)
Parameters
| Type |
Name |
Description |
| float |
time |
|
Bind(GameObject)
Binds the simulator to modelPrefabAsset: creates a hidden preview
instance, resolves its Procedural Animator components, and runs one static first frame. A no-op
when modelPrefabAsset is reference-equal to whatever was last requested — a
caller drawing every repaint (like the GUI layer) can call this unconditionally. Every failure tears
down whatever was created and leaves StatusText explaining why; it never throws and
never shows a dialog.
Declaration
public void Bind(GameObject modelPrefabAsset)
Parameters
| Type |
Name |
Description |
| GameObject |
modelPrefabAsset |
|
Dispose()
Declaration
GetStateValue(UnityStateKey)
Declaration
public float GetStateValue(UnityStateKey key)
Parameters
Returns
HasActivePulse(UnityStateKey)
Declaration
public bool HasActivePulse(UnityStateKey key)
Parameters
Returns
Pause()
Declaration
Play()
Declaration
RequestRepaint()
Requests a repaint of the hosting window — exposed so ProceduralAnimatorSimulatorGui
can drive a repaint from GUI-level input (viewport orbit drag/scroll) without this class exposing its
private repaint callback field directly.
Declaration
public void RequestRepaint()
ResetSimulation()
Rewinds simulated time to zero, stops every active action, zeroes every layer weight,
re-seeds state keys back to their minimum, and runs one static frame — the same clean-slate shape as
a fresh Bind(GameObject), without re-instantiating the preview object.
Declaration
public void ResetSimulation()
SetStateValue(UnityStateKey, float)
Declaration
public void SetStateValue(UnityStateKey key, float value)
Parameters
StartPulseAndPlay(UnityStateKey, float)
Replays a StateKeyPulse on key starting at the current
simulated time: a no-op unless bound and key is one of StateKeys.
Advancing time is required for the pulse to play out, so this ensures the clock is playing first — if
Play() refuses (e.g. entering Play Mode, which sets StatusText itself), the
pulse is dropped rather than started against a frozen clock. Overwrites any pulse already running on
the same key.
Declaration
public void StartPulseAndPlay(UnityStateKey key, float durationSeconds = 1.2)
Parameters
StepOnce()
Advances the simulation by one fixed 1/60s step. No-op while playing — stepping is a
paused-only affordance, the play/step buttons already reflect this.
Declaration
TogglePlay()
Declaration
Unbind()
Releases the preview session, stops the clock, and clears every resolved reference. Safe to
call repeatedly (idempotent) and a subsequent Bind(GameObject) — even to the same asset — rebinds
from scratch.
Declaration
Implements