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["AnimancerNodeBase"] click Base1 "/animancer/api/Animancer/AnimancerNodeBase" Base1-->Base2["Object"] Type-.->Interface0["ICopyable<AnimancerNode>"] Type-.->Interface1["IEnumerable<AnimancerState>"] Type-.->Interface2["IEnumerator"] Type-.->Interface3["IHasDescription"] click Interface3 "/animancer/api/Animancer/IHasDescription" Type-.->Interface4["IAnimationClipCollection"] click Interface4 "/animancer/api/Animancer/IAnimationClipCollection" Type-.->Interface5["ICopyable<AnimancerLayer>"] Type["AnimancerLayer"] class Type type-node

Syntax

public class AnimancerLayer : AnimancerNode, ICopyable<AnimancerNode>, IEnumerable<AnimancerState>, 
    IEnumerator, IHasDescription, IAnimationClipCollection, ICopyable<AnimancerLayer>

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
DefaultCapacity
The default Animancer.AnimancerLayer.Capacity is 8 unless changed.
static

Properties

Name Value Summary
ActiveStates IReadOnlyIndexedList<AnimancerState>
The states connected to this layer which are Animancer.AnimancerState.IsActive.
ApplyAnimatorIK bool
ApplyFootIK bool
ApplyParentAnimatorIK bool
Should setting the Animancer.AnimancerNodeBase.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.AnimancerNodeBase.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.
Capacity int
The number of states that can be connected to this layer before its UnityEngine.Playables.Playable needs to allocate more inputs.
ChildCount int
The number of nodes using this as their Animancer.AnimancerNodeBase.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 Object
[Assert-Only] The Inspector display name of this node.
Inherited from AnimancerNode
EffectiveSpeed float
The Animancer.AnimancerNodeBase.Speed of this node multiplied by the Animancer.AnimancerNodeBase.Speed of each of its parents to determine the actual speed it's playing at.
Inherited from AnimancerNodeBase
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
FadeGroup FadeGroup
The current fade being applied to this node (if any).
Inherited from AnimancerNode
FadeSpeed float
The speed at which this node is fading towards the Animancer.AnimancerNode.TargetWeight.
Inherited from AnimancerNode
Graph AnimancerGraph
The Animancer.AnimancerGraph containing this node.
Inherited from AnimancerNodeBase
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.
KeepChildrenConnected bool
Should child playables stay connected to the graph at all times?
Layer AnimancerLayer
A layer is its own root.
Mask AvatarMask
[Pro-Only] The mask that determines which bones this layer will affect.
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 AnimancerNodeBase
The object which receives the output of the Animancer.AnimancerNodeBase.Playable.
Inherited from AnimancerNodeBase
Playable Playable
The internal object this node manages in the UnityEngine.Playables.PlayableGraph.
Inherited from AnimancerNodeBase
Speed float
[Pro-Only] How fast the Animancer.AnimancerState.Time is advancing every frame (default 1).
Inherited from AnimancerNodeBase
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
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
AddContextMenuIK(GenericMenu, AnimancerNodeBase) void
[Editor-Only] Adds functions to show and set Animancer.AnimancerNodeBase.ApplyAnimatorIK and Animancer.AnimancerNodeBase.ApplyFootIK.
Inherited from AnimancerNodeBase
static
AppendDescription(StringBuilder, string) void
Appends a detailed descrption of the current details of this object.
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, AnimancerNodeBase) void
Appends the details of Animancer.AnimancerNodeBase.ApplyAnimatorIK and Animancer.AnimancerNodeBase.ApplyFootIK.
Inherited from AnimancerNode
static
AssertConnectionStatus() void
[Assert-Only] Calls Animancer.AnimancerNode.GetConnectionStatusError and logs the result if it isn't null.
Inherited from AnimancerNode
AssertConnectionStatusRecursive(AnimancerNodeBase) void
[Assert-Only] Calls Animancer.AnimancerNode.AssertConnectionStatus for the `node` and all of its children.
Inherited from AnimancerNode
static
CancelFade() void
Removes this node from the Animancer.AnimancerNode.FadeGroup.
Inherited from AnimancerNode
CopyFrom(AnimancerLayer, CloneContext) void
Copies the details of `copyFrom` into this layer.
CopyFrom(AnimancerNode, CloneContext) void
Copies the details of `copyFrom` into this node, replacing its previous contents.
CopyIKFlags(AnimancerNodeBase) void
Copies the IK settings from `copyFrom` into this node:
  • If is true, copy .
  • If is true, copy .
Inherited from AnimancerNode
CopyStatesFrom(AnimancerLayer, CloneContext, bool) void
Copies the details of all states in `copyFrom` to their equivalent states in this layer.
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`.
DestroyPlayable() void
Destroys the UnityEngine.Playables.Playable.
Inherited from AnimancerNode
DestroyStates() void
Destroys all states connected to this layer.
DisconnectChildSafe(int) void
Disconnects the UnityEngine.Playables.Playable of the child at the specified `index` from this node.
Inherited from AnimancerNode
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.
GetConnectionStatusError() string
Returns null if this node is properly connected to its parent. Otherwise, returns an error message to be logged.
Inherited from AnimancerNode
GetConstructorStackTrace(AnimancerNode) StackTrace
[Assert-Only] Returns the stack trace of the constructor (or null if Animancer.AnimancerNode.TraceConstructor was false).
Inherited from AnimancerNode
static
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.AnimancerGraph.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. The returned Animancer.AnimancerState.Time is also set to 0.
GetPath() string
Returns the hierarchy path of this node through its Animancer.AnimancerNodeBase.Parents.
Inherited from AnimancerNode
GetState(Object) AnimancerState
Returns a state registered with the `key` and attached to this layer or null if none exist.
GetTotalChildWeight() float
Calculates the total Animancer.AnimancerNode.Weight of all states in this layer.
IncrementCommandCountDev() void
[Editor-Only] [Internal] Increases the Animancer.AnimancerLayer.CommandCount by 1.
IsAnyStatePlaying() bool
Returns true if at least one animation is being played.
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.
MarkAsUsed(AnimancerNodeBase) void
[Assert-Conditional] Prevents the `node` from causing Animancer.OptionalWarning.UnusedNode.
Inherited from AnimancerNodeBase
static
OnChildIsLoopingChanged(bool) void
Called when a child's Animancer.AnimancerState.IsLooping value changes.
Inherited from AnimancerNodeBase
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
SetDebugName(Object) void
[Assert-Conditional] Sets the Animancer.AnimancerNode.DebugName to display in the Inspector.
Inherited from AnimancerNode
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.
Inherited from AnimancerNode
StartFade(float) void
Calls Animancer.AnimancerNode.OnStartFade and starts fading the Animancer.AnimancerNode.Weight over the course of the Animancer.AnimancerGraph.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
Stops the animation and makes it inactive immediately so it no longer affects the output.
Inherited from AnimancerNode
ToString() string
The Inspector display name of this layer.
TryPlay(IHasKey) AnimancerState
Stops all other animations on this layer, plays the animation registered with the `key`, and returns the animation's state.
TryPlay(IHasKey, 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` and returns the animation's state.
TryPlay(Object) AnimancerState
Stops all other animations on this layer, plays the animation registered with the `key`, and returns the animation's 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` and returns the animation's state.

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 its Animancer.AnimancerNodeBase.Playable valid?