2024-01-27 08:49:55 +08:00
|
|
|
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)
|
2025-06-01 18:36:21 +08:00
|
|
|
loadingText.text = "Starting your journey...";
|
2024-01-27 08:49:55 +08:00
|
|
|
yield return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|