Class AnimationClipPreviewScrubber
Rendered preview for the in-hub clip editor: a "Preview" foldout (collapsed by default, zero cost while collapsed, drawn via PreviewSectionGui) that owns a Serenity.Global.Infrastructure.Editor.Preview.SerenityModelPreviewSession for the panel's model and an Serenity.Global.Infrastructure.Editor.Preview.EditorPlaybackClock driving the scrub position, and blits the sampled frame through the same shared helper.
Implements
Inherited Members
Namespace: Serenity.Editor.AnimationHub.Gui
Assembly: Serenity.AnimationHub.Editor.dll
Syntax
public sealed class AnimationClipPreviewScrubber : IDisposable
Remarks
The previewed instance's UnityEngine.Animator is deliberately kept but never updated — a humanoid rig
needs the component present to retarget correctly, but edit mode never ticks it, and this scrubber drives
the pose entirely through UnityEngine.AnimationClip.SampleAnimation(UnityEngine.GameObject,System.Single) writing straight onto the instance's
transforms. If a clip ever refuses to sample that way (an object-reference-only clip, a legacy edge case),
the fallback is a manual PlayableGraph built from an AnimationClipPlayable feeding an
AnimationPlayableOutput on the instance's UnityEngine.Animator, with
DirectorUpdateMode.Manual and an explicit graph.Evaluate(deltaTime) call — contained entirely
inside Serenity.Editor.AnimationHub.Gui.AnimationClipPreviewScrubber.RenderSampledFrame(UnityEngine.Rect) if it is ever needed.
Constructors
AnimationClipPreviewScrubber(Action)
Declaration
public AnimationClipPreviewScrubber(Action repaintRequested)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | repaintRequested |
Properties
ScrubTime
Declaration
public float ScrubTime { get; }
Property Value
| Type | Description |
|---|---|
| float | The current scrub position, in clip-local seconds — read by the panel's "+K"/"−K" buttons and the Add Curve seed time so a key added while previewing lands where the user is actually looking. |
Methods
Dispose()
Releases the preview session and pauses the clock's editor-update subscription. Idempotent, and deliberately NOT terminal: the panel keeps one scrubber for its whole lifetime and calls this from every exit path (Close, Shutdown, play-mode enter, assembly reload), then reuses the same instance on the next Open — Draw() lazily recreates the session and the clock keeps working after its own Dispose (which is just a Pause).
Declaration
public void Dispose()
Draw()
Declaration
public void Draw()
MarkClipMutated(bool)
Notifies the scrubber that the clip's data changed underneath it. bindingsChanged
schedules a preview-instance reload before the next sample — SampleAnimation writes poses but
never restores them, so a curve or binding that was just removed would otherwise leave a stale pose
baked onto the instance forever. Callers that cannot know whether bindings changed (an undo, an edit
made in Unity's own Animation window) may pass false: the next sample diffs the clip's binding
signatures against the set it last sampled and reloads on its own when any disappeared. The reload is
deferred and coalesced so a burst of edits (curve-drag keystrokes) costs at most one reload per frame,
and usually none.
Declaration
public void MarkClipMutated(bool bindingsChanged)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | bindingsChanged |
SetClip(AnimationClip)
Switches to a new clip: resets the scrub position and re-reads duration/loop from the clip's
own settings. A no-op when clip is reference-equal to the clip already set.
Declaration
public void SetClip(AnimationClip clip)
Parameters
| Type | Name | Description |
|---|---|---|
| AnimationClip | clip |
SetModel(GameObject)
Switches to a new model asset: disposes the current session (it belongs to the old model's
prefab) — the next expanded Draw() lazily recreates one. A no-op when
modelAsset is reference-equal to the model already set.
Declaration
public void SetModel(GameObject modelAsset)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | modelAsset |