using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class MainMenuTransitionAnimation : MonoBehaviour { Animator animator; private void Start() { animator = GetComponent(); } 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); } AudioManager.StopAllAudio(); SceneManager.LoadScene(1); //SceneManager.sceneLoaded += () => AudioManager.stop } }