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
clip
AnimationClipAnimation clip to add to the list of playing animations
startTime
doubleTime, in seconds, at which the animation starts playing
blend
AnimationBlendOperationBlend mode - linear or additive
timeScale
floatSpeed at which the animation should play
weight
floatWeight of the animation, in regard to all other playing animations.
repeatMode
AnimationRepeatMode?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
name
stringThe name.
desiredWeight
floatThe desired weight.
fadeTimeSpan
TimeSpanThe 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
animation
PlayingAnimation
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
name
stringThe name of the animation to check
Returns
- bool
true
if the animation is playing,false
otherwise
NewPlayingAnimation(string)
public PlayingAnimation NewPlayingAnimation(string name)
Parameters
name
string
Returns
Play(string)
Plays right away the animation with the specified name, instantly removing all other blended animations.
public PlayingAnimation Play(string name)
Parameters
name
stringThe animation name.