问题
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