This commit is contained in:
Gerard Gascón 2025-04-24 17:43:50 +02:00
commit 78b901484a
323 changed files with 109774 additions and 0 deletions

View file

@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneLoader : MonoBehaviour{
[System.Serializable] public enum DifficultySelected {Easy, Hard}
public DifficultySelected difficultySelected;
Animator anim;
public static SceneLoader instance;
void Awake(){
if(instance == null){
instance = this;
}else{
Destroy(gameObject);
return;
}
DontDestroyOnLoad(gameObject);
anim = GetComponent<Animator>();
}
public void LoadScene(int scene, DifficultySelected difficulty){
anim.SetTrigger("FadeOut");
StartCoroutine(SceneChange(scene, difficulty));
}
IEnumerator SceneChange(int scene, DifficultySelected difficulty){
yield return new WaitForSeconds(1);
difficultySelected = difficulty;
AsyncOperation operation = SceneManager.LoadSceneAsync(scene);
while (!operation.isDone)
yield return null;
if (operation.isDone){
anim.SetTrigger("FadeIn");
}
}
}