来波场景跳转----个人专用代码

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

猜你喜欢

转载自blog.csdn.net/Edision_li/article/details/82625448
今日推荐