- 首页 > 睿知 > it技术 > >
Unity|Unity Spine播放动画、动画播放结束回调、停止播放
using LuaInterface;
using Spine.Unity;
using static Spine.AnimationState;
namespace LuaFramework
{
public class SpineAnimManager : Manager
{
private TrackEntryDelegate ac = null;
///
/// 播放动画
///
///
///
/// 【Unity|Unity Spine播放动画、动画播放结束回调、停止播放】
///
///
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);
}
}
}
}
推荐阅读