28 lines
675 B
C#
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;
|
|
}
|
|
}
|