c# - 如何重新启动统一动画师?

标签 c# unity3d animator

我使用了动画师来倒计时(使用手指模型为三秒)。我成功地制作了一个倒计时动画师。我想随时播放动画师,因为这个项目需要多次倒计时以进行校准。

但是我不知道怎么办。现在我想玩动画师都玩不了,也不知道怎么玩了。目前,动画师是在动画师窗口中创建的,而不是脚本。

enter image description here

最佳答案

animator.Play("animation name", layer, normalizedTime);

这是过载。 更准确地说,这样做:

animator.Play("your animation name", -1, 0f);

如果你愿意,你也可以使用协程。这是我的首选方式:

private IEnumerator Counter(int secondsToCount)
{
    while (secondsToCount >= 0)
    {
        //'counter' is the counter that appears to the player
        counter.text = secondsToCount.ToString();
        secondsToCount--;
        yield return new WaitForSeconds(1f);
    }
}

这样您就可以控制倒计时的秒数。

编辑:

如果您是新手并且对协同例程一无所知。您可以像这样启动它们:

StartCoroutine(Counter(5));

这将从 5 数到 0。

关于c# - 如何重新启动统一动画师?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44084420/

相关文章:

c# - 从 byte[] 创建 ZipFile 不再可用?

c# - 在 ASP.net C# 中,如何将参数从 Javascript 函数传递给 onclick 处理程序

c# - GUIStyle.hover 状态是否适用于 Unity 编辑器标签(或除 Button 之外的其他控件)?

c# - Unity3D : Performance with multi-camera rendering with a lot of spheric meshes

android - 使 ObjectAnimator 动画持续时间独立于开发人员选项中的全局动画持续时间比例设置

C# .NET x86/x64 哪个项目决定平台?

c# - 两个网格单元之间的距离,没有对角线

android - 某些设备上的 Animator/AnimatorSet 问题

java - Vaadin 动画师淡入刷新后消失

c# - 如何以定义的格式在输入中显示日期时间