Unity Animator - 在场景的开始和结束处制作动画

Unity Animator - Have an animation at the start and end of a scene

我是 Unity 的新手,我正在努力使用动画师创建一个简单的动画。我想要一个 GUI 在场景的开始和结束时有一个动画。进入动画为"NextLevelGUI",退出动画为"FadeOut"。我曾尝试使用脚本启用的条件将 Any State 块连接到这些动画,但这不起作用。另外,我讨厌使用 "Empty" 动画,但我不希望有动画师控制的入口动画。只编写动画脚本会更好吗?

动画师形象

您需要在开始时使用空闲动画。

使用脚本你需要做的事情:

public class BrandBtn : MonoBehaviour
{
    public Animator _anim;

    void Start()
    {
        _anim.Play("NextLevelGUI");
    }

    IEnumerator EndScene()
    {
        _anim.Play("FadeOut");
        yield return new WaitForSeconds(anim.GetCurrentAnimatorStateInfo(0).length+anim.GetCurrentAnimatorStateInfo(0).normalizedTime);
        // Load next scene
    }
}