來波場景跳轉----個人專用程式碼
阿新 • • 發佈:2018-12-09
public class LevelLoader : MonoBehaviour {
public GameObject loadingPanle; public Slider slider; public Text progressText; public void LoadLevel(int levelIndex) { StartCoroutine(LoadAsynchronously(levelIndex)); }
IEnumerator LoadAsynchronously(int sceneIndex) { AsyncOperation operation = SceneManager.LoadSceneAsync(sceneIndex); loadingPanle.SetActive(true);
while (!operation.isDone) {
float progress = Mathf.Clamp01(operation.progress / .9f); slider.value = progress; progressText.text = progress * 100 + "%"; yield return null; } } }