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.
Assembly
Animancer.dll
Namespace
Animancer
Interfaces
Base Types
  • PlayableBehaviour
graph BT Type-->Base0["PlayableBehaviour"] Type-.->Interface0["IEnumerator"] Type-.->Interface1["IPlayableWrapper"] click Interface1 "/animancer/api/Animancer/IPlayableWrapper" Type-.->Interface2["IAnimationClipCollection"] click Interface2 "/animancer/api/Animancer/IAnimationClipCollection" Type["AnimancerPlayable"] class Type type-node

Syntax

public class AnimancerPlayable : PlayableBehaviour, IEnumerator, IPlayableWrapper, 
    IAnimationClipCollection

Remarks

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.

Documentation: Playing Animations

Fields

Name Constant Value Summary
DefaultFadeDurationClass DefaultFadeDuration
[Editor-Only] The name that should be used for a class which sets the Animancer.AnimancerPlayable.DefaultFadeDuration.
static
DefaultFadeDurationNamespace Animancer
[Editor-Only] The namespace that should be used for a class which sets the Animancer.AnimancerPlayable.DefaultFadeDuration.
static

Properties

Name Value Summary
ApplyAnimatorIK bool
Should Unity call OnAnimatorIK on the animated object while this object and its children have any Animancer.AnimancerNode.Weight?
ApplyFootIK bool
Should this object and its children apply IK to the character's feet?
CommandCount int
The number of times the Animancer.AnimancerLayer.CurrentState has changed on layer 0. 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
DefaultFadeDuration float
The fade duration to use if not specified. Default is 0.25.
static
DeltaTime float
The current UnityEngine.Playables.FrameData.deltaTime.
static
Disposables List<IDisposable>
A list of objects that need to be disposed when this Animancer.AnimancerPlayable is destroyed.
FrameID ulong
The current UnityEngine.Playables.FrameData.frameId.
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
Is this Animancer.AnimancerPlayable currently usable (not destroyed)?
KeepChildrenConnected bool
Should playables stay connected to the graph at all times? Otherwise they will be disconnected when their Animancer.AnimancerNode.Weight is 0.
Layers AnimancerPlayable.LayerList
The Animancer.AnimancerLayers which each manage their own set of animations.
PostUpdatableCount int
The number of objects that have been registered by Animancer.AnimancerPlayable.RequirePostUpdate(Animancer.IUpdatable).
PreUpdatableCount int
The number of objects that have been registered by Animancer.AnimancerPlayable.RequirePreUpdate(Animancer.IUpdatable).
SkipFirstFade bool
Normally the first animation on the Base Layer should not fade in because there is nothing fading out. But sometimes that is undesirable, such as if the UnityEngine.Animator.runtimeAnimatorController is assigned since Animancer can blend with that.
Speed float
How fast the Animancer.AnimancerState.Time of all animations is advancing every frame.
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) void
Appends a detailed descrption of all currently playing states and other registered states.
AppendInternalDetails(StringBuilder, string, string) void
Appends all registered Animancer.IUpdatables and System.IDisposables.
CancelPostUpdate(IUpdatable) void
Removes the `updatable` from the list of objects that need to be updated after the playebles.
CancelPreUpdate(IUpdatable) void
Removes the `updatable` from the list of objects that need to be updated before the playables.
Create() AnimancerPlayable
Creates a new UnityEngine.Playables.PlayableGraph containing an Animancer.AnimancerPlayable.

The caller is responsible for calling Animancer.AnimancerPlayable.DestroyGraph 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
Create(PlayableGraph) AnimancerPlayable
Creates an Animancer.AnimancerPlayable in an existing UnityEngine.Playables.PlayableGraph.
static
Create<T>(PlayableGraph, T) T
Creates an Animancer.AnimancerPlayable in an existing UnityEngine.Playables.PlayableGraph.
static
CreateOutput(Animator, IAnimancerComponent) void
Plays this playable on the specified `animator` and sets the Animancer.AnimancerPlayable.Component.
CreateOutput(IAnimancerComponent) void
Plays this playable on the Animancer.IAnimancerComponent.Animator and sets the Animancer.AnimancerPlayable.Component.
DestroyGraph() void
Destroys the Animancer.AnimancerPlayable.Graph. This operation cannot be undone.
DestroyOutput() bool
Destroys the UnityEngine.Playables.PlayableOutput connected to this Animancer.AnimancerPlayable and returns true if it was found. Otherwise returns false.
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() string
Returns a detailed descrption of all currently playing states and other registered states.
GetKey(AnimationClip) Object
Calls Animancer.IAnimancerComponent.GetKey(UnityEngine.AnimationClip) on the Animancer.AnimancerPlayable.Component.
GetPostUpdatable(int) IUpdatable
Returns the object registered by Animancer.AnimancerPlayable.RequirePostUpdate(Animancer.IUpdatable) at the specified `index`.
GetPreUpdatable(int) IUpdatable
Returns the object registered by Animancer.AnimancerPlayable.RequirePreUpdate(Animancer.IUpdatable) at the specified `index`.
GetTotalWeight() float
Calculates the total Animancer.AnimancerNode.Weight of all states in all layers.
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.
InsertOutputPlayable(Playable) void
[Pro-Only] Inserts a `playable` after the root of the Animancer.AnimancerPlayable.Graph so that it can modify the final output.
IsPlaying() bool
Is least one animation being played?
IsPlaying(AnimancerState) bool
[Warning] You should not use an Animancer.AnimancerState as a key. Just check Animancer.AnimancerState.IsPlaying.
IsPlaying(IHasKey) bool
Is a state registered with the Animancer.IHasKey.Key and currently playing?
IsPlaying(Object) bool
Is a state registered with the `key` and 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.
IsRunningPostUpdate(AnimancerPlayable) bool
Indicates whether the internal Animancer.AnimancerPlayable.PostUpdate is currently executing.
static
OnPlayableCreate(Playable) void
[Internal] Called by Unity when 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 layer, plays the `state`, and returns it.
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`.
Play(AnimationClip) AnimancerState
Stops all other animations on the same layer, plays the `clip`, and returns its state.
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.
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] Calls Animancer.IUpdatable.Update on everything registered using Animancer.AnimancerPlayable.RequirePreUpdate(Animancer.IUpdatable).
RequirePostUpdate(IUpdatable) void
[Pro-Only] Adds the `updatable` to the list that need to be updated after the playables if it was not there already.
RequirePreUpdate(IUpdatable) void
[Pro-Only] Adds the `updatable` to the list that need to be updated before the playables if it was not there already.
SetDummyRoot(AnimancerNode) void
Assigns a dummy Animancer.AnimancerNode.Root to avoid Animancer.OptionalWarning.UnusedNode during Unit Tests where states are not necessarily used.
static
SetNextGraphName(string) void
[Editor-Conditional] Sets the display name for the next Animancer.AnimancerPlayable.Create call to give its UnityEngine.Playables.PlayableGraph.
static
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)".
TryGetOutput(PlayableOutput) bool
Outputs the UnityEngine.Playables.PlayableOutput connected to the Animancer.AnimancerPlayable and returns true if it was found. Otherwise returns false.
TryPlay(Object) AnimancerState
Stops all other animations on the same layer, plays the animation registered with the `key`, and returns that state. Or if no state is registered with that `key`, this method does nothing and returns null.
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`. Or if no state is registered with that `key`, this method does nothing and returns null.
UnpauseGraph() void
Resumes playing the UnityEngine.Playables.PlayableGraph if Animancer.AnimancerPlayable.PauseGraph was called previously.