Sprite Factory

ReadMe
Release Notes
Overview
Using the Editor
Upgrading

Concepts
Sprites
Master Sprites
Sprite Groups
Colliders
Locators
Material Sets
SpriteUpdater
SpriteCamera

Advanced
Working in Multiple Projects

Classes
Runtime Classes

Videos
Overview
Creating Sprites
Sprite Inspector
Frame Events
Collision System
Locator System
Material Sets

Links
Sprite Factory Site
Web Documentation
Support
Contact

SpriteFactory.Sprite.SetAnimationStartedCallback

C#: void SetAnimationStartedCallback (string animationName, System.Action callback)
JS: function SetAnimationStartedCallback (animationName : String, callback : System.Action) : void

Description
Assign a callback to run when an animation starts playing. Use this to take some action when an animation starts playing.

Example:

C#

void Start() {
    // Set up callbacks for when animations start playing
    sprite.SetAnimationStartedCallback(sprite.defaultAnimation, DefaultAnimStarted);

    // If Sprite.playDefaultAnimWhenIdle == true, we can detect when any animation finishes and we play
    // our default animation by adding this callback. This can be useful for state management.
}

private void DefaultAnimStarted() {
    // do something like setting the state to default
    Debug.Log("Default anim started playing.");
}
JS
function Start() : void {
    // Set up callbacks for when animations start playing
    sprite.SetAnimationStartedCallback(sprite.defaultAnimation, DefaultAnimStarted);

    // If Sprite.playDefaultAnimWhenIdle == true, we can detect when any animation finishes and we play
    // our default animation by adding this callback. This can be useful for state management.
}

private function DefaultAnimStarted() : void {
    // do something like setting the state to default
    Debug.Log("Default anim started playing.");
}

C#: void SetAnimationStartedCallback (int animationIndex, System.Action callback)
JS: function SetAnimationStartedCallback (animationIndex : int, callback : System.Action) : void

Description
Assign a callback to run when an animation starts playing. Use this to take some action when an animation starts playing.

Example:

C#

void Start() {
    // Set up callbacks for when animations start playing
    sprite.SetAnimationStartedCallback(sprite.defaultAnimationIndex, DefaultAnimStarted);

    // If Sprite.playDefaultAnimWhenIdle == true, we can detect when any animation finishes and we play
    // our default animation by adding this callback. This can be useful for state management.
}

private void DefaultAnimStarted() {
    // do something like setting the state to default
    Debug.Log("Default anim started playing.");
}
JS
function Start() : void {
    // Set up callbacks for when animations start playing
    sprite.SetAnimationStartedCallback(sprite.defaultAnimationIndex, DefaultAnimStarted);

    // If Sprite.playDefaultAnimWhenIdle == true, we can detect when any animation finishes and we play
    // our default animation by adding this callback. This can be useful for state management.
}

private function DefaultAnimStarted() : void {
    // do something like setting the state to default
    Debug.Log("Default anim started playing.");
}

See Also
SetAnimationFinishedCallback
SetAnimationEndedCallback