NamedAnimancerComponent Class

Summary

An Animancer.AnimancerComponent which uses the UnityEngine.Object.names of UnityEngine.AnimationClips so they can be referenced using strings as well as the clips themselves.
Assembly
Animancer.dll
Namespace
Animancer
Interfaces
Base Types
Derived Types
graph BT Type-->Base0["AnimancerComponent"] click Base0 "/animancer/api/Animancer/AnimancerComponent" Base0-->Base1["MonoBehaviour"] Type-.->Interface0["IAnimancerComponent"] click Interface0 "/animancer/api/Animancer/IAnimancerComponent" Type-.->Interface1["IEnumerator"] Type-.->Interface2["IAnimationClipSource"] Type-.->Interface3["IAnimationClipCollection"] click Interface3 "/animancer/api/Animancer/IAnimationClipCollection" Type["NamedAnimancerComponent"] class Type type-node Derived0["HybridAnimancerComponent"]-->Type click Derived0 "/animancer/api/Animancer/HybridAnimancerComponent"

Syntax

[AddComponentMenu(Strings.MenuPrefix + "Named Animancer Component")]
[HelpURL(Strings.DocsURLs.APIDocumentation + "/" + nameof(NamedAnimancerComponent))]
public class NamedAnimancerComponent : AnimancerComponent, IAnimancerComponent, IEnumerator, 
    IAnimationClipSource, IAnimationClipCollection

Examples

Named Animations

Remarks

It also has fields to automatically register animations on startup and play the first one automatically without needing another script to control it, much like Unity's Legacy UnityEngine.Animation component.

Documentation: Component Types

Attributes

Type Description
AddComponentMenu
HelpURLAttribute

Fields

Name Constant Value Summary
DefaultExecutionOrder -5000
Initialize before anything else tries to use this component.
Inherited from AnimancerComponent
static

Properties

Name Value Summary
ActionOnDisable AnimancerComponent.DisableAction
[UnityEngine.SerializeField] Determines what happens when this component is disabled or its UnityEngine.GameObject becomes inactive (i.e. in Animancer.AnimancerComponent.OnDisable).
Inherited from AnimancerComponent
Animations AnimationClip[]
[UnityEngine.SerializeField] Animations in this array will be automatically registered by Animancer.NamedAnimancerComponent.Awake as states that can be retrieved using their name and the first element will be played by Animancer.NamedAnimancerComponent.OnEnable if Animancer.NamedAnimancerComponent.PlayAutomatically is true.
Animator Animator
[UnityEngine.SerializeField] The UnityEngine.Animator component which this script controls.
Inherited from AnimancerComponent
DefaultAnimation AnimationClip
The first element in the Animancer.NamedAnimancerComponent.Animations array. It will be automatically played by Animancer.NamedAnimancerComponent.OnEnable if Animancer.NamedAnimancerComponent.PlayAutomatically is true.
InitialUpdateMode Nullable<AnimatorUpdateMode>
[Editor-Only] The Animancer.IAnimancerComponent.UpdateMode that was first used when this script initialized.
Inherited from AnimancerComponent
IsPlayableInitialized bool
Indicates whether the Animancer.AnimancerComponent.Playable has been initialized.
Inherited from AnimancerComponent
Layers AnimancerPlayable.LayerList
The layers which each manage their own set of animations.
Inherited from AnimancerComponent
Playable AnimancerPlayable
The internal system which manages the playing animations. Accessing this property will automatically initialize it.
Inherited from AnimancerComponent
PlayAutomatically bool
[UnityEngine.SerializeField] If true, the first clip in the Animancer.NamedAnimancerComponent.Animations array will be automatically played by Animancer.NamedAnimancerComponent.OnEnable.
States AnimancerPlayable.StateDictionary
The states managed by this component.
Inherited from AnimancerComponent
UpdateMode AnimatorUpdateMode
Determines when animations are updated and which time source is used. This property is mainly a wrapper around the UnityEngine.Animator.updateMode.
Inherited from AnimancerComponent

Methods

Name Value Summary
~AnimancerComponent() void
[Editor-Only] Ensures that the Animancer.AnimancerPlayable is destroyed in Edit Mode, but not in Play Mode since we want to let Unity complain if that happens.
Inherited from AnimancerComponent
Awake() void
Creates a state for each clip in the Animancer.NamedAnimancerComponent.Animations array.
Evaluate() void
Immediately applies the current states of all animations to the animated objects.
Inherited from AnimancerComponent
Evaluate(float) void
Advances time by the specified value (in seconds) and immediately applies the current states of all animations to the animated objects.
Inherited from AnimancerComponent
GatherAnimationClips(ICollection<AnimationClip>) void
[Animancer.IAnimationClipCollection] Gathers all the animations in the Animancer.AnimancerComponent.Playable.

In the Unity Editor this method also gathers animations from other components on parent and child objects.
GetAnimationClips(List<AnimationClip>) void
[UnityEngine.IAnimationClipSource] Calls Animancer.AnimancerComponent.GatherAnimationClips(System.Collections.Generic.ICollection{UnityEngine.AnimationClip}).
Inherited from AnimancerComponent
GetKey(AnimationClip) Object
Returns the clip's name.
InitializePlayable() void
Creates and initializes the Animancer.AnimancerComponent.Playable if it wasn't already initialized.
Inherited from AnimancerComponent
InitializePlayable(AnimancerPlayable) void
Sets the Animancer.AnimancerComponent.Playable and connects it to the Animancer.AnimancerComponent.Animator.
Inherited from AnimancerComponent
IsPlaying() bool
Returns true if at least one animation is being played.
Inherited from AnimancerComponent
IsPlaying(AnimancerState) bool
[Warning] You should not use an Animancer.AnimancerState as a key. Just check Animancer.AnimancerState.IsPlaying.
Inherited from AnimancerComponent
IsPlaying(AnimationClip) bool
Returns true if a state is registered for the `clip` and it is currently playing.

The actual dictionary key is determined using Animancer.AnimancerComponent.GetKey(UnityEngine.AnimationClip).
Inherited from AnimancerComponent
IsPlaying(IHasKey) bool
Returns true if a state is registered with the Animancer.IHasKey.Key and it is currently playing.
Inherited from AnimancerComponent
IsPlaying(Object) bool
Returns true if a state is registered with the `key` and it is currently playing.
Inherited from AnimancerComponent
IsPlayingClip(AnimationClip) bool
Returns true if the `clip` is currently being played by at least one state.

This method is inefficient because it searches through every state to find any that are playing the `clip`, unlike Animancer.AnimancerComponent.IsPlaying(UnityEngine.AnimationClip) which only checks the state registered using the `clip`s key.
Inherited from AnimancerComponent
OnDestroy() void
Ensures that the Animancer.AnimancerComponent.Playable is properly cleaned up.
Inherited from AnimancerComponent
OnDisable() void
Acts according to the Animancer.AnimancerComponent.ActionOnDisable.
Inherited from AnimancerComponent
OnEnable() void
Plays the first clip in the Animancer.NamedAnimancerComponent.Animations array if Animancer.NamedAnimancerComponent.PlayAutomatically is true.
OnInitializePlayable() void
Called right after the Animancer.AnimancerComponent.Playable is initialized.
Inherited from AnimancerComponent
OnValidate() void
[Editor-Only] Uses ClipState.ValidateClip to ensure that all of the clips in the Animancer.NamedAnimancerComponent.Animations array are supported by the Animancer system and removes any others.
Play(AnimancerState) AnimancerState
Stops all other animations on the same layer, plays the `state`, and returns it.
Inherited from AnimancerComponent
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`.
Inherited from AnimancerComponent
Play(AnimationClip) AnimancerState
Stops all other animations on the same layer, plays the `clip`, and returns its state.
Inherited from AnimancerComponent
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.
Inherited from AnimancerComponent
Play(ITransition) AnimancerState
Creates a state for the `transition` if it didn't already exist, then calls Animancer.AnimancerComponent.Play(Animancer.AnimancerState) or Animancer.AnimancerComponent.Play(Animancer.AnimancerState,System.Single,Animancer.FadeMode) depending on ITransition.CrossFadeFromStart.
Inherited from AnimancerComponent
Play(ITransition, float, FadeMode) AnimancerState
Creates a state for the `transition` if it didn't already exist, then calls Animancer.AnimancerComponent.Play(Animancer.AnimancerState) or Animancer.AnimancerComponent.Play(Animancer.AnimancerState,System.Single,Animancer.FadeMode) depending on ITransition.CrossFadeFromStart.
Inherited from AnimancerComponent
Reset() void
[Editor-Only] Destroys the Animancer.AnimancerComponent.Playable if it was initialized and searches for an Animancer.AnimancerComponent.Animator on this object, or it's children or parents.
Inherited from AnimancerComponent
Stop() void
Stops all animations and rewinds them to the start.
Inherited from AnimancerComponent
Stop(AnimancerState) AnimancerState
[Warning] You should not use an Animancer.AnimancerState as a key. Just call Animancer.AnimancerState.Stop.
Inherited from AnimancerComponent
Stop(AnimationClip) AnimancerState
Gets the state associated with the `clip`, stops and rewinds it to the start, then returns it.
Inherited from AnimancerComponent
Stop(IHasKey) AnimancerState
Gets the state registered with the Animancer.IHasKey.Key, stops and rewinds it to the start, then returns it.
Inherited from AnimancerComponent
Stop(Object) AnimancerState
Gets the state associated with the `key`, stops and rewinds it to the start, then returns it.
Inherited from AnimancerComponent
TryGetAnimator() bool
Tries to ensure that an Animancer.AnimancerComponent.Animator is present using UnityEngine.Component.TryGetComponent``1(``0@) if necessary.
Inherited from AnimancerComponent
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.
Inherited from AnimancerComponent
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.
Inherited from AnimancerComponent

Operators

Name Value Summary
implicit operator AnimancerLayer(AnimancerComponent) AnimancerLayer
Inherited from AnimancerComponent
implicit operator AnimancerPlayable(AnimancerComponent) AnimancerPlayable
Inherited from AnimancerComponent