AnimancerPlayable Class

Summary

A UnityEngine.Playables.PlayableBehaviour which can be used as a substitute for the UnityEngine.RuntimeAnimatorController normally used to control an UnityEngine.Animator.

This class can be used as a custom yield instruction to wait until all animations finish playing.

The most common way to access this class is via Animancer.AnimancerComponent.Playable.
Assembly
Animancer.dll
Namespace
Animancer
Interfaces
Base Types
  • PlayableBehaviour
graph BT Type-->Base0["PlayableBehaviour"] Type-.->Interface0["IEnumerable<AnimancerState>"] Type-.->Interface1["IEnumerator"] Type-.->Interface2["IPlayableWrapper"] click Interface2 "/animancer/api/Animancer/IPlayableWrapper" Type-.->Interface3["IAnimationClipCollection"] click Interface3 "/animancer/api/Animancer/IAnimationClipCollection" Type-.->Interface4["IHasIK"] click Interface4 "/animancer/api/Animancer/IHasIK" Type["AnimancerPlayable"] class Type type-node

Syntax

public sealed class AnimancerPlayable : PlayableBehaviour, IEnumerable<AnimancerState>, 
    IEnumerator, IPlayableWrapper, IAnimationClipCollection, IHasIK

Fields

Name Constant Value Summary
DefaultFadeDuration 0.25
The fade duration to use if the caller doesn't specify.
static

Properties

Name Value Summary
ApplyAnimatorIK bool
[Animancer.IHasIK] Determines whether OnAnimatorIK(int layerIndex) will be called on the animated object for any Animancer.AnimancerPlayable.States. The initial value is determined by Animancer.AnimancerPlayable.DefaultApplyAnimatorIK when a new state is created and setting this value will also set the default.

This is equivalent to the "IK Pass" toggle in Animator Controller layers, except that due to limitations in the Playables API the layerIndex will always be zero.
ApplyFootIK bool
[Animancer.IHasIK] Determines whether any of the Animancer.AnimancerPlayable.States in this layer are applying IK to the character's feet. The initial value is determined by Animancer.AnimancerPlayable.DefaultApplyFootIK when a new state is created.

This is equivalent to the "Foot IK" toggle in Animator Controller states (applied to the whole layer).
CommandCount int
The number of times the Animancer.AnimancerPlayable.StateDictionary.Current has changed. By storing this value and later comparing the stored value to the current value, you can determine whether the state has been changed since then, even it has changed back to the same state.
Component IAnimancerComponent
The component that is playing this Animancer.AnimancerPlayable.
Current AnimancerPlayable
The object currently executing Animancer.AnimancerPlayable.PrepareFrame(UnityEngine.Playables.Playable,UnityEngine.Playables.FrameData).
static
DefaultApplyAnimatorIK bool
Determines the default value of Animancer.AnimancerNode.ApplyAnimatorIK for all new states created in this layer. Default false.
DefaultApplyFootIK bool
Determines the default value of Animancer.AnimancerNode.ApplyFootIK for all new states created in this layer. Default false.
DeltaTime float
The current (most recent) UnityEngine.Playables.FrameData.deltaTime.

After Animancer.AnimancerPlayable.PrepareFrame(UnityEngine.Playables.Playable,UnityEngine.Playables.FrameData), this property will be left at its most recent value.
static
Disposables List<IDisposable>
A list of objects that need to be disposed when this Animancer.AnimancerPlayable is destroyed.
FrameID ulong
The current (most recent) UnityEngine.Playables.FrameData.frameId.

Animancer.AnimancerState.Time uses this value to determine whether it has accessed the playable's time since it was last updated in order to cache its value.
Graph PlayableGraph
[Pro-Only] The UnityEngine.Playables.PlayableGraph containing this Animancer.AnimancerPlayable.
IsGraphPlaying bool
Indicates whether the UnityEngine.Playables.PlayableGraph is currently playing.
IsValid bool
Returns true as long as the UnityEngine.Playables.PlayableGraph hasn't been destroyed (such as by Animancer.AnimancerPlayable.Destroy).
KeepChildrenConnected bool
Indicates whether child playables should stay connected to the graph at all times.
Layers AnimancerPlayable.LayerList
The Animancer.AnimancerLayers which each manage their own set of animations.
Speed float
How fast the Animancer.AnimancerState.Time of all animations is advancing every frame.

1 is the normal speed.

A negative value will play the animations backwards.

Setting this value to 0 would pause all animations, but calling Animancer.AnimancerPlayable.PauseGraph is more efficient.

Animancer Lite does not allow this value to be changed in a runtime build.
States AnimancerPlayable.StateDictionary
The Animancer.AnimancerStates managed by this playable.
UpdateMode DirectorUpdateMode
Determines what time source is used to update the UnityEngine.Playables.PlayableGraph.

Methods

Name Value Summary
~AnimancerPlayable() void
Calls System.IDisposable.Dispose on all the Animancer.AnimancerPlayable.Disposables.
AppendDescription(StringBuilder, int) void
Appends a detailed descrption of all currently playing states and other registered states.
AppendInternalDetails(StringBuilder, string, string) void
Appends a list of all Animancer.IUpdatables and Animancer.AnimancerNodes that are registered for updates.
CancelUpdate(IUpdatable) void
Removes the `updatable` from the list of objects that need to be updated.

This method is safe to call at any time, even during an update.

The last element is swapped into the place of the one being removed so that the rest of them do not need to be moved down one place to fill the gap. This is more efficient, but means that the update order can change.
Create() AnimancerPlayable
Creates a new UnityEngine.Playables.PlayableGraph containing an Animancer.AnimancerPlayable.

The caller is responsible for calling Animancer.AnimancerPlayable.Destroy on the returned object, except in Edit Mode where it will be called automatically.

Consider calling Animancer.AnimancerPlayable.SetNextGraphName(System.String) before this method to give it a name.
static
Destroy() void
Destroys the UnityEngine.Playables.PlayableGraph. This operation cannot be undone.
Evaluate() void
Evaluates all of the currently playing animations to apply their states to the animated objects.
Evaluate(float) void
Advances all currently playing animations by the specified amount of time (in seconds) and evaluates the graph to apply their states to the animated objects.
GatherAnimationClips(ICollection<AnimationClip>) void
[Animancer.IAnimationClipCollection] Gathers all the animations in all layers.
GetDescription(int) string
Returns a detailed descrption of all currently playing states and other registered states.
GetEnumerator() IEnumerator<AnimancerState>
Returns an enumerator that will iterate through all states in each layer (but not sub-states).
GetKey(AnimationClip) Object
Calls Animancer.IAnimancerComponent.GetKey(UnityEngine.AnimationClip) on the Animancer.AnimancerPlayable.Component.
GetTotalWeight() float
Calculates the total Animancer.AnimancerNode.Weight of all states in this playable.
HasChangedToOrFromAnimatePhysics(Nullable<AnimatorUpdateMode>, AnimatorUpdateMode) bool
[Editor-Only] Returns true if the `initial` mode was UnityEngine.AnimatorUpdateMode.AnimatePhysics and the `current` has changed to another mode or if the `initial` mode was something else and the `current` has changed to UnityEngine.AnimatorUpdateMode.AnimatePhysics.
static
InsertOutputJob<T>(T) AnimationScriptPlayable
[Pro-Only] Inserts an animation job after the root of the Animancer.AnimancerPlayable.Graph so that it can modify the final output.

It can can be removed by passing the returned value into Animancer.AnimancerUtilities.RemovePlayable(UnityEngine.Playables.Playable,System.Boolean).
InsertOutputPlayable(Playable) void
[Pro-Only] Inserts a `playable` after the root of the Animancer.AnimancerPlayable.Graph so that it can modify the final output.

It can be removed using Animancer.AnimancerUtilities.RemovePlayable(UnityEngine.Playables.Playable,System.Boolean).
IsPlaying() bool
Returns true if at least one animation is being played.
IsPlaying(AnimancerState) bool
[Warning] You should not use an Animancer.AnimancerState as a key. Just check Animancer.AnimancerState.IsPlaying.
IsPlaying(IHasKey) bool
Returns true if a state is registered with the Animancer.IHasKey.Key and it is currently playing.
IsPlaying(Object) bool
Returns true if a state is registered with the `key` and it is currently playing.
IsPlayingClip(AnimationClip) bool
Returns true if the `clip` is currently being played by at least one state in the specified layer.

This method is inefficient because it searches through every state to find any that are playing the `clip`, unlike Animancer.AnimancerPlayable.IsPlaying(System.Object) which only checks the state registered using the specified key.
IsRunningLateUpdate(AnimancerPlayable) bool
Indicates whether the internal Animancer.AnimancerPlayable.LateUpdate is currently executing.
static
OnPlayableCreate(Playable) void
[Internal] Called by Unity as it creates this Animancer.AnimancerPlayable.
OnPlayableDestroy(Playable) void
Cleans up the resources managed by this Animancer.AnimancerPlayable.
PauseGraph() void
Freezes the UnityEngine.Playables.PlayableGraph at its current state.

If you call this method, you are responsible for calling Animancer.AnimancerPlayable.UnpauseGraph to resume playing.
Play(AnimancerState) AnimancerState
Stops all other animations on the same laye, plays the `state`, and returns it.

The animation will continue playing from its current Animancer.AnimancerState.Time. If you wish to force it back to the start, you can simply set the `state`s time to 0.
Play(AnimancerState, float, FadeMode) AnimancerState
Starts fading in the `state` while fading out all others in the same layer over the course of the `fadeDuration`. Returns the `state`.

If the `state` was already playing and fading in with less time remaining than the `fadeDuration`, this method will allow it to complete the existing fade rather than starting a slower one.

If the layer currently has 0 Animancer.AnimancerNode.Weight, this method will fade in the layer itself and simply Animancer.AnimancerState.Play the `state`.

Animancer Lite only allows the default `fadeDuration` (0.25 seconds) in a runtime build.
Play(AnimationClip) AnimancerState
Stops all other animations on the same layer, plays the `clip`, and returns its state.

The animation will continue playing from its current Animancer.AnimancerState.Time. To restart it from the beginning you can use ...Play(clip, layerIndex).Time = 0;.
Play(AnimationClip, float, FadeMode) AnimancerState
Starts fading in the `clip` while fading out all other states in the same layer over the course of the `fadeDuration`. Returns its state.

If the `state` was already playing and fading in with less time remaining than the `fadeDuration`, this method will allow it to complete the existing fade rather than starting a slower one.

If the layer currently has 0 Animancer.AnimancerNode.Weight, this method will fade in the layer itself and simply Animancer.AnimancerState.Play the `state`.

Animancer Lite only allows the default `fadeDuration` (0.25 seconds) in a runtime build.
Play(ITransition) AnimancerState
Creates a state for the `transition` if it didn't already exist, then calls Animancer.AnimancerPlayable.Play(Animancer.AnimancerState) or Animancer.AnimancerPlayable.Play(Animancer.AnimancerState,System.Single,Animancer.FadeMode) depending on the Animancer.ITransition.FadeDuration.
Play(ITransition, float, FadeMode) AnimancerState
Creates a state for the `transition` if it didn't already exist, then calls Animancer.AnimancerPlayable.Play(Animancer.AnimancerState) or Animancer.AnimancerPlayable.Play(Animancer.AnimancerState,System.Single,Animancer.FadeMode) depending on the Animancer.ITransition.FadeDuration.
PrepareFrame(Playable, FrameData) void
[Internal] Called by the UnityEngine.Playables.PlayableGraph before the rest of the UnityEngine.Playables.Playables are evaluated. Calls Animancer.IUpdatable.EarlyUpdate and Animancer.AnimancerNode.Update(System.Boolean@) on everything that needs it.
RequireUpdate(AnimancerNode) void
Adds the `node` to the list that need to be updated if it was not there already.

This method is safe to call at any time, even during an update.

The execution order of nodes is non-deterministic. Specifically, the most recently added will be updated first and Animancer.AnimancerPlayable.CancelUpdate(Animancer.AnimancerNode) will change the order by swapping the last one into the place of the removed element.
RequireUpdate(IUpdatable) void
Adds the `updatable` to the list of objects that need to be updated if it was not there already.

This method is safe to call at any time, even during an update.

The execution order of updatables is non-deterministic. Specifically, the most recently added will be updated first and Animancer.AnimancerPlayable.CancelUpdate(Animancer.IUpdatable) will change the order by swapping the last one into the place of the removed element.
SetNextGraphName(string) void
[Editor-Conditional] Sets the display name for the next Animancer.AnimancerPlayable.Create call to give its UnityEngine.Playables.PlayableGraph.
static
SetOutput(Animator, IAnimancerComponent) void
Plays this playable on the specified `animator`.
SetOutput(IAnimancerComponent) void
Plays this playable on the Animancer.IAnimancerComponent.Animator.
Stop() void
Calls Animancer.AnimancerState.Stop on all animations to stop them from playing and rewind them to the start.
Stop(AnimancerState) AnimancerState
[Warning] You should not use an Animancer.AnimancerState as a key. Just call Animancer.AnimancerState.Stop.
Stop(IHasKey) AnimancerState
Gets the state registered with the Animancer.IHasKey.Key, stops and rewinds it to the start, then returns it.
Stop(Object) AnimancerState
Calls Animancer.AnimancerState.Stop on the state registered with the `key` to stop it from playing and rewind it to the start.
ToString() string
[Editor-Only] Returns "AnimancerPlayable (Graph Name)".
TryPlay(Object) AnimancerState
Stops all other animations on the same layer, plays the animation registered with the `key`, and returns that state.

The animation will continue playing from its current Animancer.AnimancerState.Time. If you wish to force it back to the start, you can simply set the returned state's time to 0. on the returned state.
TryPlay(Object, float, FadeMode) AnimancerState
Starts fading in the animation registered with the `key` while fading out all others in the same layer over the course of the `fadeDuration`.

If the `state` was already playing and fading in with less time remaining than the `fadeDuration`, this method will allow it to complete the existing fade rather than starting a slower one.

If the layer currently has 0 Animancer.AnimancerNode.Weight, this method will fade in the layer itself and simply Animancer.AnimancerState.Play the `state`.

Animancer Lite only allows the default `fadeDuration` (0.25 seconds) in a runtime build.
UnpauseGraph() void
Resumes playing the UnityEngine.Playables.PlayableGraph if Animancer.AnimancerPlayable.PauseGraph was called previously.