Init repository
This commit is contained in:
Executable file
+33
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class AdvLevelMan : MonoBehaviour
|
||||
{
|
||||
public Slider loadingBar;
|
||||
public TMP_Text loadingText;
|
||||
|
||||
public void SwitchSceneAdv(string levelName)
|
||||
{
|
||||
StartCoroutine(LoadSceneAsync(levelName));
|
||||
}
|
||||
|
||||
IEnumerator LoadSceneAsync(string levelName)
|
||||
{
|
||||
Debug.Log($"Loading scene {levelName}");
|
||||
AsyncOperation op = SceneManager.LoadSceneAsync(levelName);
|
||||
while (!op.isDone)
|
||||
{
|
||||
float progress = Mathf.Clamp01(op.progress / .9f);
|
||||
//Debug.Log(op.progress);
|
||||
loadingBar.value = progress;
|
||||
loadingText.text = $"<align=center>{(progress * 100f).ToString("0.00")}%";
|
||||
if ((progress * 100f) >= 98)
|
||||
loadingText.text = "Doing stuff...";
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user