赞
踩
using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; using System.Collections; public class GotoSceneForAsyncOperation : MonoBehaviour { public GameObject loadScene; public Slider loadSlider; public Text showText; public void LoadNextScene() { StartCoroutine(Loadlevel()); } IEnumerator Loadlevel() { loadScene.SetActive(true); AsyncOperation operation = SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex + 1); operation.allowSceneActivation = false; while (!operation.isDone) { loadSlider.value = operation.progress; showText.text = operation.progress * 100 + "%"; if (operation.progress >= 0.9f) { loadSlider.value = 1; showText.text = "Pls enter any keys~"; if (Input.anyKeyDown) { operation.allowSceneActivation = true; } } yield return null; } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。