如何在动画师中获得状态?

时间:2018-06-06 04:47:18

标签: c# unity3d

如何从动画师那里获取状态。我试图通过状态获取动画的剪辑长度,我现在的问题是,下面的代码只适用于动画片段,但如果我有额外的状态链接到同一个片段,它不会工作

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;
}

enter image description here

我可以获得walk剪辑,但我无法得到walk_auto的剪辑,这是额外的状态。

0 个答案:

没有答案
相关问题