Hello,
I recently started to use Spine in Unity but i'm missing a lot of "terms" to fully use my animations in it.
For exemple i want to "destroy" my gameobject containing the animation, after it end, but i don't know how to check if the current animation is ended, or if it as already loop X time.
(also is there a way to dynamically change the SkeletonDataAsset or set it to null (to avoid Destroying every gameobject in the end of an animation, to reuse the same gameobject later for other animations ?)
Thanks in advance^^.
I got something that works, not perfect since i manually add the track number, i would prefer an "animation name" in the "getCurrent" instead of the animation index but, i post it if it can help others :
public class Animation_autoDestroy : MonoBehaviour
{
public static SkeletonAnimation skeletonAnimation;
public static TrackEntry trackEntry;
// Use this for initialization
void Start()
{
skeletonAnimation = GetComponent<SkeletonAnimation>();
trackEntry = skeletonAnimation.AnimationState.GetCurrent(0);
trackEntry.TrackEnd = trackEntry.Animation.Duration; // check the time of the animation
}
void Update()
{
if (trackEntry.IsComplete) // if animation complete, delete it
{
Destroy(this.gameObject);
}
}
}