Unity Animator-在场景的开始和结束处制作动画 [英] Unity Animator - Have an animation at the start and end of a scene

查看:460
本文介绍了Unity Animator-在场景的开始和结束处制作动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Unity的新手,我正努力用动画师创建一个简单的动画.我希望GUI在场景的开头和结尾处具有动画.入口动画为"NextLevelGUI",出口为"FadeOut".我尝试使用脚本启用的条件将任意状态"块连接到这些动画,但这不起作用.另外,我不想使用空"动画,但我不希望有动画师控制的进入动画.仅编写动画脚本会更好吗?

I'm new to Unity, and I'm struggling to create a simple animation with the animator. I want a GUI to have an animation at the beginning and end of a scene. The entry animation is "NextLevelGUI", and the exit is "FadeOut". I've attempted connecting the Any State block to these animations with conditions enabled by the scripts, but this does not work. Also, I hate to use an "Empty" animation, but I don't want there to be a animator-controlled entry animation. Would it be better just to script the animations?

动画师图片

推荐答案

使用您需要执行的脚本:

Using script you need to do:

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

这篇关于Unity Animator-在场景的开始和结束处制作动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆