using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; using UnityEngine.Events; namespace Manager { class SenceManager:MonoSingleton { UnityAction onProgress = null; public void LoadScene(int name) { StartCoroutine(LoadLevel(name)); } IEnumerator LoadLevel( int id) { Debug.LogFormat("LoadLevel: {0}", name); AsyncOperation async = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(id); async.allowSceneActivation = true; async.completed += LevelLoadCompleted; //保存数据 PlayerInfo.Instance.info.currentMap=id; SaveSystem.SaveDate(PlayerInfo.Instance.info.DatePath, PlayerInfo.Instance.info); while (!async.isDone) { if (onProgress != null) onProgress(async.progress); yield return null; } } private void LevelLoadCompleted(AsyncOperation obj) { if (onProgress != null) onProgress(1f); Debug.Log("LevelLoadCompleted:" + obj.progress); } } }