init
This commit is contained in:
commit
9afd57306d
323 changed files with 204673 additions and 0 deletions
40
Assets/LevelLoader.cs
Normal file
40
Assets/LevelLoader.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class LevelLoader : MonoBehaviour{
|
||||
|
||||
public static LevelLoader Instance;
|
||||
|
||||
public Animator transition;
|
||||
public float transitionTime = 1f;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake(){
|
||||
if(Instance == null){
|
||||
Instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
void Start(){
|
||||
Time.timeScale = 0;
|
||||
StartCoroutine(EnableTimeScale());
|
||||
}
|
||||
|
||||
public void LoadLevel(string scene){
|
||||
StartCoroutine(LevelTransition(scene));
|
||||
}
|
||||
|
||||
IEnumerator EnableTimeScale(){
|
||||
yield return new WaitForSecondsRealtime(transitionTime);
|
||||
Time.timeScale = 1;
|
||||
}
|
||||
|
||||
IEnumerator LevelTransition(string scene){
|
||||
transition.SetTrigger("Start");
|
||||
Time.timeScale = 0;
|
||||
yield return new WaitForSecondsRealtime(transitionTime);
|
||||
SceneManager.LoadScene(scene);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue