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.
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["IUpdatable"] click Interface0 "/animancer/api/Animancer/IUpdatable" Type-.->Interface1["Key.IListItem"] click Interface1 "/animancer/api/Animancer/IListItem" Type-.->Interface2["IEnumerable<AnimancerState>"] Type-.->Interface3["IEnumerator"] Type-.->Interface4["IPlayableWrapper"] click Interface4 "/animancer/api/Animancer/IPlayableWrapper" Type-.->Interface5["ICopyable<AnimancerNode>"] Type-.->Interface6["IAnimationClipCollection"] click Interface6 "/animancer/api/Animancer/IAnimationClipCollection" Type["AnimancerLayer"] class Type type-node

Syntax

public sealed class AnimancerLayer : AnimancerNode, IUpdatable, Key.IListItem, 
    IEnumerable<AnimancerState>, IEnumerator, IPlayableWrapper, ICopyable<AnimancerNode>, 
    IAnimationClipCollection

Remarks

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

Documentation: Layers

Fields

Name Constant Value Summary
NotInList -1
The Animancer.Key._Index which indicates that an item isn't in a list.
Inherited from Key
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?
ApplyParentAnimatorIK bool
Should setting the Animancer.AnimancerNode.Parent also set this node's Animancer.AnimancerNode.ApplyAnimatorIK to match it? Default is true.
Inherited from AnimancerNode
static
ApplyParentFootIK bool
Should setting the Animancer.AnimancerNode.Parent also set this node's Animancer.AnimancerNode.ApplyFootIK to match it? Default is true.
Inherited from AnimancerNode
static
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.
DebugName string
[Assert-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
EffectiveWeight float
The Animancer.AnimancerNode.Weight of this state multiplied by the Animancer.AnimancerNode.Weight of each of its parents down the hierarchy to determine how much this state affects the final output.
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 Animancer.AnimancerNode.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
Is the Animancer.AnimancerNode.Playable usable (properly initialized 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.
MaxCloneCount int
The maximum number of duplicate states that can be created for a single clip when trying to get a weightless state. Exceeding this limit will cause it to just use the state with the lowest weight. Default = 3.
static
Parent IPlayableWrapper
The Animancer.AnimancerNode.Root receives the output of the UnityEngine.Playables.Playable.
Playable Playable
The internal UnityEngine.Playables.Playable managed by this node.
Inherited from AnimancerNode
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 (default 1).
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.
TraceConstructor bool
[Assert-Only] Should a System.Diagnostics.StackTrace be captured in the constructor of all new nodes so Animancer.OptionalWarning.UnusedNode can include it in the warning if that node ends up being unused?
Inherited from AnimancerNode
static
UnsupportedSpeedMessage string
[Assert-Only] Returns null if the Animancer.AnimancerNode.Speed property will work properly on this type of node, or a message explaining why it won't work.
Inherited from AnimancerNode
Weight float
The current blend weight of this node which determines how much it affects the final output.
Inherited from AnimancerNode
WeightlessThreshold float
The maximum Animancer.AnimancerNode.Weight that Animancer.AnimancerLayer.GetOrCreateWeightlessState(Animancer.AnimancerState) will treat as being weightless. Default = 0.1.
static

Methods

Name Value Summary
~AnimancerNode() void
[Assert-Only] Checks Animancer.OptionalWarning.UnusedNode.
Inherited from AnimancerNode
AddChild(AnimancerState) void
Adds a new port and uses Animancer.AnimancerState.SetParent(Animancer.AnimancerNode,System.Int32) to connect the `state` to it.
AppendDescription(StringBuilder, 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.String) to append the details of this node.
AppendIKDetails(StringBuilder, string, IPlayableWrapper) void
Appends the details of Animancer.IPlayableWrapper.ApplyAnimatorIK and Animancer.IPlayableWrapper.ApplyFootIK.
Inherited from AnimancerNode
static
ApplyWeight() void
Applies the Animancer.AnimancerNode.Weight to the connection between this node and its Animancer.AnimancerNode.Parent.
Inherited from AnimancerNode
AssertConnectionWeight() void
[Assert-Only] Logs an error if the weight of the connection between the Animancer.AnimancerNode.Parent and this node does not match the Animancer.AnimancerNode.Weight.
Inherited from AnimancerNode
AssertConnectionWeightRecursive(IPlayableWrapper) void
[Assert-Only] Calls Animancer.AnimancerNode.AssertConnectionWeight for this node and all of its children.
Inherited from AnimancerNode
static
CopyIKFlags(AnimancerNode) void
Copies the IK settings from the Animancer.AnimancerNode.Parent:
  • If is true, copy .
  • If is true, copy .
Inherited from AnimancerNode
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 Animancer.AnimancerNode.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`.
DestroyPlayable() void
Destroys the Animancer.AnimancerNode.Playable.
Inherited from AnimancerNode
DestroyStates() void
Destroys all states connected to this layer.
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.
GetConstructorStackTrace(AnimancerNode) StackTrace
[Assert-Only] Returns the stack trace of the constructor (or null if Animancer.AnimancerNode.TraceConstructor was false).
Inherited from AnimancerNode
static
GetDescription(string) string
Returns a detailed descrption of the current details of this node.
Inherited from AnimancerNode
GetEnumerator() FastEnumerator<AnimancerState>
Gets an enumerator for all of this node's child states.
GetOrCreateState(AnimancerState) AnimancerState
Returns the `state` if it's a child of this layer. Otherwise makes a clone of it.
GetOrCreateState(AnimationClip, bool) AnimancerState
Calls Animancer.AnimancerPlayable.GetKey(UnityEngine.AnimationClip) and returns the state 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 registered with the `key` or creates one if it doesn't exist.
GetOrCreateWeightlessState(AnimancerState) AnimancerState
If the `state`'s Animancer.AnimancerNode.Weight is not currently low, this method finds or creates a copy of it which is low. he returned Animancer.AnimancerState.Time is also set to 0.
GetState(Object) AnimancerState
Returns a state registered with the `key` and attached to this layer or null if none exist.
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
Is the `key` currently in a keyed list?
Inherited from Key
static
IsPlayingAndNotEnding() bool
Returns true if the Animancer.AnimancerLayer.CurrentState is playing and hasn't yet reached its end.

This method is called by System.Collections.IEnumerator.MoveNext so this object can be used as a custom yield instruction to wait until it finishes.
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 on the same layer, plays the `state`, and returns it.
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`.
Play(AnimationClip) AnimancerState
Stops all other animations on this layer, plays the `clip`, and returns its state.
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.
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.
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.RequirePreUpdate(Animancer.IUpdatable) if the Animancer.AnimancerNode.Root is not null.
Inherited from AnimancerNode
SetDebugName(string) void
[Assert-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.
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) void
Calls Animancer.AnimancerNode.OnStartFade and starts fading the Animancer.AnimancerNode.Weight over the course of the Animancer.AnimancerPlayable.DefaultFadeDuration (in seconds).
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).
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.
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.

Extension Methods

Name Value Summary
CalculateEditorFadeDuration(float) float
[Animancer Extension] [Editor-Only] Returns the duration of the `node`s current fade (if any), otherwise returns the `defaultDuration`.
IsValid() bool
[Animancer Extension] Is the `node` is not null and Animancer.AnimancerNode.IsValid?