Fur-War/Assets/Scripts/Menu/LevelLoader.cs
Gerard Gascón 3b4c6e0ec6 init
2025-04-24 17:29:51 +02:00

28 lines
675 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelLoader : MonoBehaviour{
Animator anim;
[SerializeField, Range(0f, 3f)] float fadeDuration = 1f;
public static LevelLoader instance;
void Awake(){
instance = this;
anim = GetComponent<Animator>();
}
public void LoadScene(int scene){
StartCoroutine(LoadLevel(scene));
}
IEnumerator LoadLevel(int scene){
anim.SetTrigger("Fade");
yield return new WaitForSecondsRealtime(fadeDuration);
SceneManager.LoadSceneAsync(scene);
Time.timeScale = 1;
}
}