fgm24/Assets/Scripts/Misc/MainMenuTransitionAnimation.cs

34 lines
817 B
C#
Raw Normal View History

2024-02-03 00:34:11 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2024-02-03 18:02:20 +01:00
using UnityEngine.SceneManagement;
2024-02-03 00:34:11 +01:00
public class MainMenuTransitionAnimation : MonoBehaviour
{
Animator animator;
private void Start()
{
animator = GetComponent<Animator>();
}
public void AnimationMainMenuStart()
{
animator.SetTrigger("Start");
2024-02-03 18:02:20 +01:00
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);
2024-02-03 00:34:11 +01:00
}
}