///获取动画状态机animator的动画clip的播放持续时长
public static float GetClipLength(Animator animator, string clipName)
{
if(null== animator ||
string.IsNullOrEmpty(clip) ||
null == animator.runtimeAnimatorController)
return 0;
// 获取所有的clips
var clips = animator.runtimeAnimatorController.animationClips;
if( null == clips || clips.Length <= 0) return 0;
AnimationClip clip ;
for (int i = 0, len = clips.Length; i < len ; ++i)
{
clip = ac.animationClips[i];
if(null != clip && clip.name == clipName)
return clip.Length;
}
return 0f;
}
Unity通过Animator获取动画clip时长
最新推荐文章于 2024-03-21 18:20:23 发布