Header menu logo Nu

AnimationState Type

Applies animations over time, queues animations for later playback, mixes (crossfading) between animations, and applies multiple animations on top of each other (layering).

See Applying Animations in the Spine Runtimes Guide.

Constructors

Constructor Description

AnimationState(data)

Full Usage: AnimationState(data)

Parameters:
data : AnimationStateData

Instance members

Instance member Description

this.AddAnimation

Full Usage: this.AddAnimation

Parameters:
    trackIndex : int
    animationName : string
    loop : bool
    delay : float32

Returns: TrackEntry

Queues an animation by name.

trackIndex : int
animationName : string
loop : bool
delay : float32
Returns: TrackEntry

this.AddAnimation

Full Usage: this.AddAnimation

Parameters:
    trackIndex : int
    animation : Animation
    loop : bool
    delay : float32 - If > 0, sets TrackEntry.Delay. If <= 0, the delay set is the duration of the previous track entry minus any mix duration (from the AnimationStateData plus the specified Delay (ie the mix ends at (Delay = 0) or before (Delay < 0) the previous track entry duration). If the previous entry is looping, its next loop completion is used instead of its duration.

Returns: TrackEntry A track entry to allow further customization of animation playback. References to the track entry must not be kept after the AnimationState.Dispose event occurs.

Adds an animation to be played after the current or last queued animation for a track. If the track is empty, it is equivalent to calling AnimationState.SetAnimation.

trackIndex : int
animation : Animation
loop : bool
delay : float32

If > 0, sets TrackEntry.Delay. If <= 0, the delay set is the duration of the previous track entry minus any mix duration (from the AnimationStateData plus the specified Delay (ie the mix ends at (Delay = 0) or before (Delay < 0) the previous track entry duration). If the previous entry is looping, its next loop completion is used instead of its duration.

Returns: TrackEntry

A track entry to allow further customization of animation playback. References to the track entry must not be kept after the AnimationState.Dispose event occurs.

this.AddEmptyAnimation

Full Usage: this.AddEmptyAnimation

Parameters:
    trackIndex : int - Track number.
    mixDuration : float32 - Mix duration.
    delay : float32 - If > 0, sets TrackEntry.Delay. If <= 0, the delay set is the duration of the previous track entry minus any mix duration plus the specified Delay (ie the mix ends at (Delay = 0) or before (Delay < 0) the previous track entry duration). If the previous entry is looping, its next loop completion is used instead of its duration.

Returns: TrackEntry A track entry to allow further customization of animation playback. References to the track entry must not be kept after the AnimationState.Dispose event occurs.

Adds an empty animation to be played after the current or last queued animation for a track, and sets the track entry's TrackEntry.MixDuration. If the track is empty, it is equivalent to calling AnimationState.SetEmptyAnimation.

trackIndex : int

Track number.

mixDuration : float32

Mix duration.

delay : float32

If > 0, sets TrackEntry.Delay. If <= 0, the delay set is the duration of the previous track entry minus any mix duration plus the specified Delay (ie the mix ends at (Delay = 0) or before (Delay < 0) the previous track entry duration). If the previous entry is looping, its next loop completion is used instead of its duration.

Returns: TrackEntry

A track entry to allow further customization of animation playback. References to the track entry must not be kept after the AnimationState.Dispose event occurs.

this.AddEventSubscribersFrom

Full Usage: this.AddEventSubscribersFrom

Parameters:
src : AnimationState

this.Apply

Full Usage: this.Apply

Parameters:
Returns: bool True if any animations were applied.

Poses the skeleton using the track entry animations. The animation state is not changed, so can be applied to multiple skeletons to pose them identically.

skeleton : Skeleton
Returns: bool

True if any animations were applied.

this.ApplyEventTimelinesOnly

Full Usage: this.ApplyEventTimelinesOnly

Parameters:
    skeleton : Skeleton
    ?issueEvents : bool - When set to false, only animation times of TrackEntries are updated.

Returns: bool

Version of AnimationState.Apply only applying and updating time at EventTimelines for lightweight off-screen updates.

skeleton : Skeleton
?issueEvents : bool

When set to false, only animation times of TrackEntries are updated.

Returns: bool

this.AssignEventSubscribersFrom

Full Usage: this.AssignEventSubscribersFrom

Parameters:
src : AnimationState

this.ClearListenerNotifications

Full Usage: this.ClearListenerNotifications

 Discards all listener notifications that have not yet been delivered. This can be useful to call from an
            AnimationState event subscriber when it is known that further notifications that may have been already queued for delivery
            are not wanted because new animations are being set.

this.ClearNext

Full Usage: this.ClearNext

Parameters:

Removes the TrackEntry.Next and all entries after it for the specified entry.

entry : TrackEntry

this.ClearTrack

Full Usage: this.ClearTrack

Parameters:
    trackIndex : int

Removes all animations from the track, leaving skeletons in their current pose.

It may be desired to use AnimationState.SetEmptyAnimation to mix the skeletons back to the setup pose, rather than leaving them in their current pose.

trackIndex : int

this.ClearTracks

Full Usage: this.ClearTracks

Removes all animations from all tracks, leaving skeletons in their current pose.

It may be desired to use AnimationState.SetEmptyAnimations to mix the skeletons back to the setup pose, rather than leaving them in their current pose.

this.Complete

Full Usage: this.Complete

Returns: TrackEntryDelegate

See for details. Usage in C# and spine-unity is explained on the spine-unity documentation pages.

Returns: TrackEntryDelegate

this.Data

Full Usage: this.Data

The AnimationStateData to look up mix durations.

this.Dispose

Full Usage: this.Dispose

Returns: TrackEntryDelegate

See for details. Usage in C# and spine-unity is explained on the spine-unity documentation pages.

Returns: TrackEntryDelegate

this.End

Full Usage: this.End

Returns: TrackEntryDelegate

See for details. Usage in C# and spine-unity is explained on the spine-unity documentation pages.

Returns: TrackEntryDelegate

this.Event

Full Usage: this.Event

Returns: TrackEntryEventDelegate
Returns: TrackEntryEventDelegate

this.GetCurrent

Full Usage: this.GetCurrent

Parameters:
    trackIndex : int

Returns: TrackEntry The track entry for the animation currently playing on the track, or null if no animation is currently playing.
trackIndex : int
Returns: TrackEntry

The track entry for the animation currently playing on the track, or null if no animation is currently playing.

this.Interrupt

Full Usage: this.Interrupt

Returns: TrackEntryDelegate

See for details. Usage in C# and spine-unity is explained on the spine-unity documentation pages.

Returns: TrackEntryDelegate

this.SetAnimation

Full Usage: this.SetAnimation

Parameters:
    trackIndex : int
    animationName : string
    loop : bool

Returns: TrackEntry

Sets an animation by name. AnimationState.SetAnimation

trackIndex : int
animationName : string
loop : bool
Returns: TrackEntry

this.SetAnimation

Full Usage: this.SetAnimation

Parameters:
    trackIndex : int
    animation : Animation
    loop : bool - If true, the animation will repeat. If false it will not, instead its last frame is applied if played beyond its duration. In either caseTrackEntry.TrackEnd determines when the track is cleared.

Returns: TrackEntry A track entry to allow further customization of animation playback. References to the track entry must not be kept after the AnimationState.Dispose event occurs.

Sets the current animation for a track, discarding any queued animations. If the formerly current track entry was never applied to a skeleton, it is replaced (not mixed from).

trackIndex : int
animation : Animation
loop : bool

If true, the animation will repeat. If false it will not, instead its last frame is applied if played beyond its duration. In either caseTrackEntry.TrackEnd determines when the track is cleared.

Returns: TrackEntry

A track entry to allow further customization of animation playback. References to the track entry must not be kept after the AnimationState.Dispose event occurs.

this.SetEmptyAnimation

Full Usage: this.SetEmptyAnimation

Parameters:
    trackIndex : int
    mixDuration : float32

Returns: TrackEntry

Sets an empty animation for a track, discarding any queued animations, and sets the track entry's !:TrackEntry.getMixDuration(). An empty animation has no timelines and serves as a placeholder for mixing in or out.

Mixing out is done by setting an empty animation with a mix duration using either AnimationState.SetEmptyAnimation, AnimationState.SetEmptyAnimations, or AnimationState.AddEmptyAnimation. Mixing to an empty animation causes the previous animation to be applied less and less over the mix duration. Properties keyed in the previous animation transition to the value from lower tracks or to the setup pose value if no lower tracks key the property. A mix duration of 0 still mixes out over one frame.

Mixing in is done by first setting an empty animation, then adding an animation using AnimationState.AddAnimation with the desired delay (an empty animation has a duration of 0) and on the returned track entry, set the !:TrackEntry.SetMixDuration(float). Mixing from an empty animation causes the new animation to be applied more and more over the mix duration. Properties keyed in the new animation transition from the value from lower tracks or from the setup pose value if no lower tracks key the property to the value keyed in the new animation.

trackIndex : int
mixDuration : float32
Returns: TrackEntry

this.SetEmptyAnimations

Full Usage: this.SetEmptyAnimations

Parameters:
    mixDuration : float32

Sets an empty animation for every track, discarding any queued animations, and mixes to it over the specified mix duration.

mixDuration : float32

this.Start

Full Usage: this.Start

Returns: TrackEntryDelegate

See for details. Usage in C# and spine-unity is explained on the spine-unity documentation pages.

Returns: TrackEntryDelegate

this.TimeScale

Full Usage: this.TimeScale

Multiplier for the delta time when the animation state is updated, causing time for all animations and mixes to play slower or faster. Defaults to 1.

See TrackEntry TrackEntry.TimeScale for affecting a single animation.

this.ToString

Full Usage: this.ToString

Returns: string
Modifiers: abstract
Returns: string

this.Tracks

Full Usage: this.Tracks

Returns: ExposedList<TrackEntry>

A list of tracks that have animations, which may contain nulls.

Returns: ExposedList<TrackEntry>

this.Update

Full Usage: this.Update

Parameters:
    delta : float32 - delta time

Increments the track entry TrackEntry.TrackTime, setting queued animations as current if needed.

delta : float32

delta time

Type something to start searching.