Unity通过Animator获取动画clip时长

///获取动画状态机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; AnimationClipclip ; 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; }

    推荐阅读