Animancer v6.0 is currently available for testing.

AnimancerLayer Class

Summary

A layer on which animations can play with their states managed independantly of other layers while blending the output with those layers.
Assembly
Animancer.dll
Namespace
Animancer
Interfaces
Base Types
graph BT Type-->Base0["AnimancerNode"] click Base0 "/animancer/api/Animancer/AnimancerNode" Base0-->Base1["Key"] click Base1 "/animancer/api/Animancer/Key" Base1-->Base2["Object"] Type-.->Interface0["IKeyedListItem"] click Interface0 "/animancer/api/Animancer/IKeyedListItem" Type-.->Interface1["IEnumerable<AnimancerState>"] Type-.->Interface2["IEnumerator"] Type-.->Interface3["IPlayableWrapper"] click Interface3 "/animancer/api/Animancer/IPlayableWrapper" Type-.->Interface4["IAnimationClipCollection"] click Interface4 "/animancer/api/Animancer/IAnimationClipCollection" Type-.->Interface5["IHasIK"] click Interface5 "/animancer/api/Animancer/IHasIK" Type["AnimancerLayer"] class Type type-node

Syntax

public sealed class AnimancerLayer : AnimancerNode, IKeyedListItem, IEnumerable<AnimancerState>, 
    IEnumerator, IPlayableWrapper, IAnimationClipCollection, IHasIK

Remarks

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

Documentation: Layers

Properties

Name Value Summary
ApplyAnimatorIK bool
[Animancer.IHasIK] Determines whether OnAnimatorIK(int layerIndex) will be called on the animated object while this node and its children are active. The initial value is determined by Animancer.AnimancerPlayable.DefaultApplyAnimatorIK.

This is equivalent to the "IK Pass" toggle in Animator Controller layers.

Note that this property only applies to Animancer.ClipStates.
Inherited from AnimancerNode
ApplyFootIK bool
[Animancer.IHasIK] Determines whether this node and its children are applying IK to the character's feet. The initial value is determined by Animancer.AnimancerPlayable.DefaultApplyFootIK.

This is equivalent to the "Foot IK" toggle in Animator Controller states.

Note that this property only applies to Animancer.ClipStates.
Inherited from AnimancerNode
AverageVelocity Vector3
The average velocity of the root motion of all currently playing animations, taking their current Animancer.AnimancerNode.Weight into account.
ChildCount int
[Animancer.IPlayableWrapper] The number of states using this node as their Animancer.AnimancerState.Parent.
CommandCount int
The number of times the Animancer.AnimancerLayer.CurrentState 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.
CurrentState AnimancerState
The state of the animation currently being played.

Specifically, this is the state that was most recently started using any of the Play or CrossFade methods on this layer. States controlled individually via methods in the Animancer.AnimancerState itself will not register in this property.

Each time this property changes, the Animancer.AnimancerLayer.CommandCount is incremented.
EditorName string
[Editor-Only] The Inspector display name of this node.
Inherited from AnimancerNode
EffectiveSpeed float
The Animancer.AnimancerNode.Speed of this node multiplied by the Animancer.AnimancerNode.Speed of each of its parents to determine the actual speed it's playing at.
Inherited from AnimancerNode
FadeSpeed float
The speed at which this node is fading towards the Animancer.AnimancerNode.TargetWeight.
Inherited from AnimancerNode
Index int
The index of the port this node is connected to on the parent's UnityEngine.Playables.Playable.
Inherited from AnimancerNode
IsAdditive bool
[Pro-Only] Determines whether this layer is set to additive blending. Otherwise it will override any earlier layers.
IsValid bool
Indicates whether the Animancer.AnimancerNode._Playable is usable (properly initialised and not destroyed).
Inherited from AnimancerNode
KeepChildrenConnected bool
Indicates whether child playables should stay connected to this layer at all times.
Layer AnimancerLayer
A layer is its own root.
Parent IPlayableWrapper
The Animancer.AnimancerNode.Root receives the output of the UnityEngine.Playables.Playable.
Root AnimancerPlayable
The Animancer.AnimancerPlayable at the root of the graph.
Inherited from AnimancerNode
Speed float
[Pro-Only] How fast the Animancer.AnimancerState.Time is advancing every frame.

1 is the normal speed.

A negative value will play the animation backwards.
Inherited from AnimancerNode
TargetWeight float
The desired Animancer.AnimancerNode.Weight which this node is fading towards according to the Animancer.AnimancerNode.FadeSpeed.
Inherited from AnimancerNode
this[int] AnimancerState
Returns the state connected to the specified `index` as a child of this layer.
Weight float
The current blend weight of this node which determines how much it affects the final output. 0 has no effect while 1 applies the full effect of this node and values inbetween apply a proportional effect.

Setting this property cancels any fade currently in progress. If you don't wish to do that, you can use Animancer.AnimancerNode.SetWeight(System.Single) instead.

Animancer Lite only allows this value to be set to 0 or 1 in runtime builds.
Inherited from AnimancerNode

Methods

Name Value Summary
AddChild(AnimancerState) void
Adds a new port and uses Animancer.AnimancerState.SetParent(Animancer.AnimancerNode,System.Int32) to connect the `state` to it.
AppendDescription(StringBuilder, int, string) void
Appends a detailed descrption of the current details of this node.
Inherited from AnimancerNode
AppendDetails(StringBuilder, string) void
Called by Animancer.AnimancerNode.AppendDescription(System.Text.StringBuilder,System.Int32,System.String) to append the details of this node.
CreateIfNew(AnimationClip, AnimationClip) void
Calls Animancer.AnimancerLayer.GetOrCreateState(UnityEngine.AnimationClip,System.Boolean) for each of the specified clips.

If you only want to create a single state, use Animancer.AnimancerLayer.CreateState(UnityEngine.AnimationClip).
CreateIfNew(AnimationClip, AnimationClip, AnimationClip) void
Calls Animancer.AnimancerLayer.GetOrCreateState(UnityEngine.AnimationClip,System.Boolean) for each of the specified clips.

If you only want to create a single state, use Animancer.AnimancerLayer.CreateState(UnityEngine.AnimationClip).
CreateIfNew(AnimationClip, AnimationClip, AnimationClip, AnimationClip) void
Calls Animancer.AnimancerLayer.GetOrCreateState(UnityEngine.AnimationClip,System.Boolean) for each of the specified clips.

If you only want to create a single state, use Animancer.AnimancerLayer.CreateState(UnityEngine.AnimationClip).
CreateIfNew(AnimationClip[]) void
Calls Animancer.AnimancerLayer.GetOrCreateState(UnityEngine.AnimationClip,System.Boolean) for each of the specified clips.

If you only want to create a single state, use Animancer.AnimancerLayer.CreateState(UnityEngine.AnimationClip).
CreatePlayable() void
Creates and assigns the UnityEngine.Playables.Playable managed by this node.
Inherited from AnimancerNode
CreatePlayable(Playable) void
Creates and assigns the UnityEngine.Animations.AnimationMixerPlayable managed by this layer.
CreateState(AnimationClip) ClipState
Creates and returns a new Animancer.ClipState to play the `clip`.
CreateState(Object, AnimationClip) ClipState
Creates and returns a new Animancer.ClipState to play the `clip` and registers it with the `key`.
CreateState<T>() T
Creates and returns a new T attached to this layer.
DestroyPlayable() void
Destroys the UnityEngine.Playables.Playable.
Inherited from AnimancerNode
DestroyStates() void
Destroys all states connected to this layer. This operation cannot be undone.
GatherAnimationClips(ICollection<AnimationClip>) void
[Animancer.IAnimationClipCollection] Gathers all the animations in this layer.
GetChild(int) AnimancerState
Returns the state connected to the specified `index` as a child of this layer.
GetDescription(int, string) string
Returns a detailed descrption of the current details of this node.
Inherited from AnimancerNode
GetEnumerator() IEnumerator<AnimancerState>
Returns an enumerator that will iterate through all states connected directly to this layer (not inside Animancer.MixerStates).
GetOrCreateState(AnimationClip, bool) AnimancerState
Calls Animancer.AnimancerPlayable.GetKey(UnityEngine.AnimationClip) and returns the state which registered with that key or creates one if it doesn't exist.

If the state already exists but has the wrong Animancer.AnimancerState.Clip, the `allowSetClip` parameter determines what will happen. False causes it to throw an System.ArgumentException while true allows it to change the Animancer.AnimancerState.Clip. Note that the change is somewhat costly to performance to use with caution.
GetOrCreateState(ITransition) AnimancerState
Returns the state registered with the Animancer.IHasKey.Key if there is one. Otherwise this method uses Animancer.ITransition.CreateState to create a new one and registers it with that key before returning it.
GetOrCreateState(Object, AnimationClip, bool) AnimancerState
Returns the state which registered with the `key` or creates one if it doesn't exist.

If the state already exists but has the wrong Animancer.AnimancerState.Clip, the `allowSetClip` parameter determines what will happen. False causes it to throw an System.ArgumentException while true allows it to change the Animancer.AnimancerState.Clip. Note that the change is somewhat costly to performance to use with caution.
GetOrCreateWeightlessState(AnimancerState) AnimancerState
If the `state` is not currently at 0 Animancer.AnimancerNode.Weight, this method finds a copy of it which is at 0 or creates a new one.
GetTotalWeight() float
Calculates the total Animancer.AnimancerNode.Weight of all states in this layer.
IndexOf(Key) int
Returns location of this object in the list (or -1 if it is not currently in a keyed list).
Inherited from Key
static
IsAnyStatePlaying() bool
Returns true if at least one animation is being played.
IsInList(Key) bool
Indicates whether the specified object is currently in a keyed list.
Inherited from Key
static
IsPlayingClip(AnimationClip) bool
Returns true if the `clip` is currently being played by at least one state.
OnAddChild(IList<AnimancerState>, AnimancerState) void
Connects the `state` to this node at its Animancer.AnimancerNode.Index.
Inherited from AnimancerNode
Play(AnimancerState) AnimancerState
Stops all other animations, 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` over the course of the `fadeDuration` while fading out all others in this layer. 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 runtime builds.
Play(AnimationClip) AnimancerState
Stops all other animations, 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).Time = 0;.
Play(AnimationClip, float, FadeMode) AnimancerState
Starts fading in the `clip` over the course of the `fadeDuration` while fading out all others in the same layer. 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 runtime builds.
Play(ITransition) AnimancerState
Creates a state for the `transition` if it didn't already exist, then calls Animancer.AnimancerLayer.Play(Animancer.AnimancerState) or Animancer.AnimancerLayer.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.AnimancerLayer.Play(Animancer.AnimancerState) or Animancer.AnimancerLayer.Play(Animancer.AnimancerState,System.Single,Animancer.FadeMode) depending on the Animancer.ITransition.FadeDuration.
Play(Object) AnimancerState
Stops all other animations, plays the animation registered with the `key`, and returns that state. If no state is registered with the `key`, this method does nothing and returns null.

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.
Play(Object, float, FadeMode) AnimancerState
Starts fading in the animation registered with the `key` over the course of the `fadeDuration` while fading out all others in the same layer. Returns the animation's state (or null if none was registered).

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 runtime builds.
RecreatePlayable() void
Calls Animancer.AnimancerNode.DestroyPlayable and Animancer.AnimancerNode.CreatePlayable.
Inherited from AnimancerNode
RecreatePlayableRecursive() void
Calls Animancer.AnimancerNode.RecreatePlayable on this node and all its children recursively.
Inherited from AnimancerNode
RequireUpdate() void
Calls Animancer.AnimancerPlayable.RequireUpdate(Animancer.AnimancerNode) as long as the Animancer.AnimancerNode.Root is not null.
Inherited from AnimancerNode
SetEditorName(string) void
[Editor-Conditional] Sets the Inspector display name of this node. Animancer.AnimancerNode.ToString returns the name.
Inherited from AnimancerNode
SetMask(AvatarMask) void
[Pro-Only] Sets an UnityEngine.AvatarMask to determine which bones this layer will affect.
SetMaxStateDepth(int) void
[Assert-Conditional] Sets the MaxStateDepth.
static
SetWeight(float) void
Sets the current blend weight of this node which determines how much it affects the final output. 0 has no effect while 1 applies the full effect of this node.

This method allows any fade currently in progress to continue. If you don't wish to do that, you can set the Animancer.AnimancerNode.Weight property instead.

Animancer Lite only allows this value to be set to 0 or 1 in runtime builds.
Inherited from AnimancerNode
StartFade(float, float) void
Calls Animancer.AnimancerNode.OnStartFade and starts fading the Animancer.AnimancerNode.Weight over the course of the `fadeDuration` (in seconds).

If the `targetWeight` is 0 then Animancer.AnimancerNode.Stop will be called when the fade is complete.

If the Animancer.AnimancerNode.Weight is already equal to the `targetWeight` then the fade will end immediately.

Animancer Lite only allows a `targetWeight` of 0 or 1 and the default `fadeDuration` (0.25 seconds) in runtime builds.
Inherited from AnimancerNode
Stop() void
Sets Animancer.AnimancerNode.Weight = 0 and calls Animancer.AnimancerState.Stop on all animations to stop them from playing and rewind them to the start.
ToString() string
The Inspector display name of this layer.

Extension Methods

Name Value Summary
CalculateEditorFadeDuration(float) float
Returns the duration of the `node`s current fade (if any), otherwise returns the `defaultDuration`.
IsValid() bool
Returns true if the `node` is not null and Animancer.AnimancerNode.IsValid.