獲得Animator當前播放的AnimationClip

AnimatorClipInfo
Description
Information about clip being played and blended by the Animator.
獲得Animator的當前AnimationClip和混合動畫的信息

Variables

clipReturns the animation clip played by the Animator.返回當前播放的AnimationClip
weightReturns the blending weight used by the Animator to blend this clip.返回該AnimationClip在播放中所有AnimationClip的權重

Animator

GetCurrentAnimationClipStateGets the list of AnimationInfo currently played by the current state.獲取當前狀態播放的當前動畫信息列表。
GetCurrentAnimatorStateInfoGets the current State information on a specified AnimatorController layer.獲取指定的AnimatorController層的當前狀態信息。



        Animator anim = new Animator();//獲得Animator
        AnimatorClipInfo[] animatorClipInfo = anim.GetCurrentAnimatorClipInfo(0);//獲得播放列表
        AnimatorStateInfo animatorStateInfo = anim.GetCurrentAnimatorStateInfo(0);
        foreach (AnimatorClipInfo a in animatorClipInfo) {
            AnimationClip an = a.clip;
        }
第三種方法
  AnimationClip clip = NpcAnimator.runtimeAnimatorController.animationClips[0];
        Debug.Log("animationClips[0]" + clip.name);


發佈了37 篇原創文章 · 獲贊 7 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章