Unity使用Spine动画,UGUI

//引入命名空间
using Spine.Unity;
public class UI_Rooster_Main : MonoBehaviour
 {
//龙骨对象
 public SkeletonGraphic Spine_Hero;
 void Start ()
 {
   //使用动画之前首先执行一下以下两个方法,不然会出现问题
   Spine_Hero.Skeleton.SetToSetupPose();
   Spine_Hero.AnimationState.ClearTracks();
   //切换某个动画,第三个参数是否循环
   Spine_Hero.AnimationState.SetAnimation(0, "run", false);
   //动画完成后的回调
   Spine_Hero.AnimationState.Complete += delegate
     {
            if (Spine_Hero.AnimationState.GetCurrent(0).animation.name == "run")
            {
            Debug.Log("奔跑完成的回调");
            }
            if (Spine_Hero.AnimationState.GetCurrent(0).animation.name == "att")
            {
               Debug.Log("攻击完成回调");
            }
            if (Spine_Hero.AnimationState.GetCurrent(0).animation.name == "jump")
            {
                 Debug.Log("跳跃完成回调");
            }
        };
 }

 }

你可能感兴趣的:(unity)