获取spine动画时间
Posted 那个妹子留步
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取spine动画时间相关的知识,希望对你有一定的参考价值。
public static float GetCurrentAniTime(Transform skeletonAnimation,string name)
{
if (skeletonAnimation == null)
{
Debug.LogError("(skeletonAnimation Transform == null");
}
SkeletonAnimation skeleton = skeletonAnimation.GetComponent<SkeletonAnimation>();
float duration = 0;
if (skeleton == null)
{
SkeletonGraphic skeletonGraphic = skeletonAnimation.GetComponent<SkeletonGraphic>();
if (skeletonGraphic == null)
{
Debug.LogError("(skeletonAnimation == null");
}
else
{
var skeletonData = skeletonGraphic.
skeletonDataAsset.GetAnimationStateData().SkeletonData;
if (skeletonData.FindAnimation(name)!=null)
{
duration = (float)Math.Round(skeletonData.FindAnimation(name).Duration);
}
else
{
Debug.LogError($"dont Find Animation {name}");
}
}
}
else
{
duration = (float)Math.Round(skeleton.
skeletonDataAsset.GetAnimationStateData().SkeletonData.FindAnimation(name).Duration);
}
return duration;
}
以上是关于获取spine动画时间的主要内容,如果未能解决你的问题,请参考以下文章