khc In general, the startingAnimation
property of the SkeletonGraphic
component should not be used to set an animation from code. Use AnimationState API to set an animation to your skeleton.
The following is a simple example script that sets the Idle
animation with loop:true
to track 0
of the AnimationState
of the SkeletonGraphic
component of the GameObject to which this script is attached:
using Spine.Unity;
using System.Collections;
using UnityEngine;
public class SetAnimationToSkeletonGraphic : MonoBehaviour
{
SkeletonGraphic skeletonGraphic;
void Start()
{
skeletonGraphic = GetComponent<SkeletonGraphic>();
skeletonGraphic.AnimationState.SetAnimation(0, "Idle", true);
}
}
See the API Reference for more information on the SetAnimation() method of AnimationState.