AnimationBlendSelector1D Class
Drives a SpriteAnimator by selecting and transitioning between animation clips based on a single continuous float value (e.g., movement speed, health ratio, aim angle).
public sealed class AnimationBlendSelector1D
Inheritance System.Object → AnimationBlendSelector1D
Remarks¶
When two adjacent nodes both have a speed override, Speed is linearly interpolated between them as Value moves between their thresholds.
When RespectNonLoopingClips is true (default), the tree yields to
non-looping clips started outside the tree and resumes once they finish.
Set CrossFadeDuration to cross-fade on node changes instead of hard-cutting.
| Properties | |
|---|---|
| ActiveClip | Gets the name of the clip currently selected by the tree, or null if no nodes have been added. |
| AllowZeroSpeed | When false (default), node speed values are floored at 0.001 to prevent accidentally freezing the animator. Set to true when a node speed of exactly 0 is intentional (e.g. a freeze-at-threshold behaviour). |
| CrossFadeDuration | When greater than zero, node changes trigger a cross-fade of this duration (seconds) instead of a hard cut. Defaults to 0. The fade is only initiated on clip changes; speed-only updates within the same node do not start a new fade. |
| IsEnabled | When false, evaluation is a no-op and the tree stops driving the animator. The current clip continues playing untouched. Defaults to true. |
| NodeCount | Gets the number of nodes currently registered in the tree. |
| RespectNonLoopingClips | When true (default), the tree will not interrupt a non-looping clip that was started outside the tree. Set to false to give the tree unconditional ownership of the animator. |
| Value | The current blend parameter. Setting this triggers an immediate evaluation so ActiveClip and the underlying SpriteAnimator reflect the new value right away. |
| Methods | |
|---|---|
| AddNode(float, string, Nullable<float>) | Adds a node associating a threshold value with a clip name. Nodes are kept sorted by threshold ascending. Evaluates immediately after adding. |
| CaptureSnapshot() | Captures the tree's current runtime state. Node definitions are not included. |
| ClearNodes() | Removes all nodes from the tree. |
| Evaluate() | Evaluates the tree against the current Value and updates the animator when dirty or when the active clip has finished. Called automatically by AnimationSystem each tick to handle once-clip restarts. |
| RemoveNode(float) | Removes the first node whose threshold is within 1e-6 of threshold. Returns true if a node was removed. Evaluates immediately after removing. |
| RemoveNode(string) | Removes the first node whose clip name equals clipName. Returns true if a node was removed. Evaluates immediately after removing. |
| RestoreSnapshot(AnimationBlendSelector1DSnapshot) | Restores a previously captured snapshot and evaluates immediately. |
| ValidateNodes() | Checks that every node's clip name is registered on the underlying animator. Returns a list of human-readable issue strings. An empty list means all nodes are valid. Call this after adding nodes during setup, just as you would call ValidateTransitions() for the state machine. |
| Events | |
|---|---|
| OnClipChanged | Raised when the active clip selection changes. Provides the previous clip name (or null if none was active) and the new clip name. |