如何从动画师那里获取状态。我试图通过状态获取动画的剪辑长度,我现在的问题是,下面的代码只适用于动画片段,但如果我有额外的状态链接到同一个片段,它不会工作
public static AnimationClip GetAnimationClip(Animator animator, string name)
{
//can't get data if no animator
if (animator == null)
return null;
//favor for above foreach due to performance issues
for (int i = 0; i < animator.runtimeAnimatorController.animationClips.Length; i++)
{
if (animator.runtimeAnimatorController.animationClips[i].name == name)
return animator.runtimeAnimatorController.animationClips[i];
}
Debug.LogError("Animation clip: " + name + " not found");
return null;
}
我可以获得walk
剪辑,但我无法得到walk_auto
的剪辑,这是额外的状态。