Hello! I’m trying to make a transition animation between 2 scenes. Basically, when the user hits a button, the animation should play in front while the scene changes in the background.
My animation is a series of PNGs which I imported to Unity 5.6 as an animation, set it as “Legacy”, unchecked “Play Automatically”. Then I set the animation to a game object and attached this script to it:
if (Input.GetKeyDown("space"))
{
StartCoroutine(TransitionWinner());
}
IEnumerator TransitionWinner()
{
GetComponent<Animation>().CrossFade("TransitionAni");
yield return new WaitForSeconds (GetComponent<Animation>()["TransitionAni"].length);
SceneManager.LoadScene("Winner");
}
What happens is that the animation doesn’t play at all, but the scene changes after the duration of the animation is finished.
What am i missing? (I would also like to add that I’m a beginner in Unity, so please provide an easy to understand answer. Thank you!)