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 = $"{(progress * 100f).ToString("0.00")}%"; if ((progress * 100f) >= 98) loadingText.text = "Starting your journey..."; yield return null; } } }