一、API概念
1、Spine.AnimationState支持的事件:
2、Start:当动画开始播放;
3、End:当动画被清除或中断;
4、Complete:当动画完成它全部的持续时间;
5、Event:当检测到用户自定义的事件;
二、使用
private List<System.Action> mUnRegisterEventActions = new List<System.Action>(); public void UseSpine() {// xxxSpine 是 SkeletonGraphic 类型的变量PlaySpineAddEvent(xxxSpine, "spine动画文件", false, () => { leftSpine.AnimationState.SetAnimation(0, "spine动画文件执行Anim的名称", true); }); } // 执行Spined动画并添加事件 public void PlaySpineAddEvent(SkeletonGraphic anim, string name, bool isLoop = false, System.Action action = null) { anim.AnimationState.SetAnimation(0, name, isLoop); TrackEntryDelegate ac = delegate { action(); }; anim.AnimationState.Complete += ac; mUnRegisterEventActions.Add(() => { anim.AnimationState.Complete -= ac; }); } public void UnRegisterAll() { mUnRegisterEventActions.ForEach(action => action()); mUnRegisterEventActions.Clear(); } 123456789101112131415161718192021222324252627282930313233