init
This commit is contained in:
commit
001bb14f16
951 changed files with 270074 additions and 0 deletions
27
Assets/Scripts/Level/LevelLoader.cs
Normal file
27
Assets/Scripts/Level/LevelLoader.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LevelLoader : MonoBehaviour{
|
||||
|
||||
public GameObject loadingScreen;
|
||||
public Slider slider;
|
||||
|
||||
public void LoadLevel(int sceneIndex){
|
||||
StartCoroutine(LoadAsychronously(sceneIndex));
|
||||
}
|
||||
|
||||
IEnumerator LoadAsychronously (int sceneIndex){
|
||||
AsyncOperation operation = SceneManager.LoadSceneAsync(sceneIndex);
|
||||
|
||||
loadingScreen.SetActive(true);
|
||||
|
||||
while (!operation.isDone){
|
||||
float progress = Mathf.Clamp01(operation.progress / .9f);
|
||||
slider.value = progress;
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue