fgm24/Assets/Scripts/Misc/MainMenuTransitionAnimation.cs

34 lines
817 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MainMenuTransitionAnimation : MonoBehaviour
{
Animator animator;
private void Start()
{
animator = GetComponent<Animator>();
}
public void AnimationMainMenuStart()
{
animator.SetTrigger("Start");
StartCoroutine(WaitBeforeSceneChange());
}
private IEnumerator WaitBeforeSceneChange()
{
var animInfo = animator.GetCurrentAnimatorStateInfo(0);
while (!(animInfo.normalizedTime >= 0.99f && animInfo.IsName("MenuTransition")))
{
animInfo = animator.GetCurrentAnimatorStateInfo(0);
yield return new WaitForSecondsRealtime(0.1f);
}
SceneManager.LoadScene(1);
}
}