Get the duration of Unity Animator's new animation (method call)

 private float a;

 float GetActionLenth(string name)//通过name用于获取动作长度
    {
        AnimationClip[] clip = an.runtimeAnimatorController.animationClips;
        //遍历所有的动作
        foreach (var item in clip)
        {
            //找到所对应的名称动作    
            if (item.name.Equals(name))
            {
                a = name.Length;//动作时长赋值
            }
        }
        return a;//返回时长
    }

Guess you like

Origin blog.csdn.net/m0_71624363/article/details/129541974