Class AnimationComponent
[DataContract("AnimationComponent")]
[DefaultEntityComponentProcessor(typeof(AnimationProcessor), ExecutionMode = ExecutionMode.Runtime|ExecutionMode.Thumbnail|ExecutionMode.Preview)]
[Display("Animations", null, Expand = ExpandRule.Once)]
[ComponentOrder(2000)]
[ComponentCategory("Animation")]
public sealed class AnimationComponent : EntityComponent, IIdentifiable
- Inheritance
-
AnimationComponent
- Implements
- Inherited Members
Remarks
Data is stored as in http://altdevblogaday.com/2011/10/23/low-level-animation-part-2/.
Constructors
AnimationComponent()
public AnimationComponent()
Properties
Animations
Gets the animations associated to the component.
public Dictionary<string, AnimationClip> Animations { get; }
Property Value
BlendTreeBuilder
public IBlendTreeBuilder BlendTreeBuilder { get; set; }
Property Value
Blender
public AnimationBlender Blender { get; }
Property Value
PlayingAnimations
Gets list of active animations. Use this to customize startup animations.
public TrackingCollection<PlayingAnimation> PlayingAnimations { get; }
Property Value
Methods
Add(AnimationClip, double, AnimationBlendOperation, float, float, AnimationRepeatMode?)
Adds a new playing animation at the end of the list. It doesn't alter currently playing animations.
public PlayingAnimation Add(AnimationClip clip, double startTime = 0, AnimationBlendOperation blend = AnimationBlendOperation.LinearBlend, float timeScale = 1, float weight = 1, AnimationRepeatMode? repeatMode = null)
Parameters
clipAnimationClipAnimation clip to add to the list of playing animations
startTimedoubleTime, in seconds, at which the animation starts playing
blendAnimationBlendOperationBlend mode - linear or additive
timeScalefloatSpeed at which the animation should play
weightfloatWeight of the animation, in regard to all other playing animations.
repeatModeAnimationRepeatMode?Repeat mode - play once or loop indefinitely
Returns
- PlayingAnimation
The added playing animation
Blend(string, float, TimeSpan)
Blends progressively a new animation.
public PlayingAnimation Blend(string name, float desiredWeight, TimeSpan fadeTimeSpan)
Parameters
namestringThe name.
desiredWeightfloatThe desired weight.
fadeTimeSpanTimeSpanThe fade time span.
Returns
Exceptions
- ArgumentException
name
Crossfade(string, TimeSpan)
Crossfades to a new animation.
public PlayingAnimation Crossfade(string name, TimeSpan fadeTimeSpan)
Parameters
Returns
Exceptions
- ArgumentException
name
Ended(PlayingAnimation)
Returns an awaitable object that will be completed when the animation is removed from the PlayingAnimation list.
public Task Ended(PlayingAnimation animation)
Parameters
animationPlayingAnimation
Returns
Remarks
This happens when:
- RepeatMode is PlayOnce and animation reached end
- Animation faded out completely (due to blend to 0.0 or crossfade out)
- Animation was manually removed from AnimationComponent.PlayingAnimations
IsPlaying(string)
Returns true if the specified animation is in the list of currently playing animations
public bool IsPlaying(string name)
Parameters
namestringThe name of the animation to check
Returns
- bool
trueif the animation is playing,falseotherwise
NewPlayingAnimation(string)
public PlayingAnimation NewPlayingAnimation(string name)
Parameters
namestring
Returns
Play(string)
Plays right away the animation with the specified name, instantly removing all other blended animations.
public PlayingAnimation Play(string name)
Parameters
namestringThe animation name.