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

☆樱花仙子☆ 提交于 2019-12-24 08:39:50

问题


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?

Animator image


回答1:


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



回答2:


You need to use idle animation at the start.



来源:https://stackoverflow.com/questions/49589929/unity-animator-have-an-animation-at-the-start-and-end-of-a-scene

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!