using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class SceneLoad : MonoSingleton { public GameObject loadingPanel; private void Start() { loadingPanel.SetActive(false); } public void SceneChange(string Scenename) { Debug.Log("Scenename---" + Scenename); StartCoroutine(LoadScene(Scenename)); } private IEnumerator LoadScene(string loadSceneName) //设置协程类型方法loadlevel { loadingPanel.SetActive(true); AsyncOperation operation = SceneManager.LoadSceneAsync(loadSceneName); operation.allowSceneActivation = false; while (!operation.isDone) { if (operation.progress >= 0.9f) { operation.allowSceneActivation = true; } yield return null; } loadingPanel.SetActive(false); } }