小编Dhe*_*gra的帖子

Unity3D 获取动画控制器当前动画时间

大家好,我正在尝试构建一个应用程序并尝试在滚动条上做事。

我在 Unity 的 Animator Controller 中有 3 个不同的层,所有权重为 1。在具有加载动画的第一层和具有滚动动画的第 2 层中,需要在第 1 层动画的顶部播放用它。

因此,为了在滚动上调用动画,我编写了一个程序,该程序在滚动的基础上调用动画,因此第 2 层“take001”上的动画在滚动上播放取决于发生了多少滚动。

现在我想获取第 2 层动画的当前时间。

找到下面的代码和我在Unity中创建的图层的截图:

[参考图片]:https : //imgur.com/j4Up4OE

using UnityEngine;
using System.Collections;
public class MouseMovementScript : MonoBehaviour {
Animator anim;
AnimatorStateInfo stateInfo;
AnimatorClipInfo[] myAnimatorClip;
double speedBase = 1;
void Start () {
     anim = GetComponent<Animator>();
     stateInfo = anim.GetCurrentAnimatorStateInfo(1);
    //Output the name of the starting clip

}

// Update is called once per frame
void Update () {

    var d = Input.GetAxis("Mouse ScrollWheel");

    if …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine

3
推荐指数
1
解决办法
7776
查看次数

标签 统计

c# ×1

unity-game-engine ×1