init
This commit is contained in:
commit
78b901484a
323 changed files with 109774 additions and 0 deletions
45
Assets/Scripts/SceneLoader.cs
Normal file
45
Assets/Scripts/SceneLoader.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue