1. 程式人生 > >來波場景跳轉----個人專用程式碼

來波場景跳轉----個人專用程式碼

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;         }     } }