Unity Spine播放动画、动画播放结束回调、停止播放

using LuaInterface;
using Spine.Unity;
using static Spine.AnimationState;

namespace LuaFramework
{
    public class SpineAnimManager : Manager
    {
        private TrackEntryDelegate ac = null;
        /// 
        /// 播放动画
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        public void PlayAnim(SkeletonGraphic skeleton, LuaFunction func,int trackIndex, string animName,bool loop)
        {
            if (skeleton != null)
            {
                PlayAnim(skeleton, trackIndex, animName, loop);
                ac = delegate
                {
                    if (func != null)
                    {
                        func.Call();
                    }
                    skeleton.AnimationState.Complete -= ac;
                    ac = null;
                };
                skeleton.AnimationState.Complete += ac;
            }
        }
        /// 
        /// 停止动画播放
        /// 
        /// 
        /// 
        public void StopAnim(SkeletonGraphic sg, int trackIndex, float mixDuration)
        {
            sg.AnimationState.SetEmptyAnimation(trackIndex, mixDuration);
        }

        /// 
        /// 播放动画
        /// 
        /// 
        /// 
        /// 
        /// 
        public void PlayAnim(SkeletonGraphic skeleton, int trackIndex, string animName, bool loop)
        {
            if (skeleton != null)
            {
                skeleton.AnimationState.SetAnimation(trackIndex, animName, loop);
            }
        }
    }
}

你可能感兴趣的:(Unity,C#,笔记,unity)