public BaseLoadInfo ResourceLoadAsync(string path, OnLoadEnd onLoadEnd) { BaseLoadInfo loadinfo = FindLoadedImp(path); if (loadinfo != null) { loadinfo.AddRef(); if (loadinfo.LoadedState == BaseLoadInfo.LoadState.Loding) { if (onLoadEnd != null) { loadinfo.WaitLoadAsync(onLoadEnd); } } else { if (onLoadEnd != null) { onLoadEnd(loadinfo); } } return(loadinfo); } return(ResourceLoadAsyncImp(path, onLoadEnd)); }
IEnumerator WaitForLoadLevel(int level, bool additive = false) { loadingScreen.Show(); OnLoadBegin.Dispatch(); #if (UNITY_5_2 || UNITY_5_1 || UNITY_5_0) AsyncOperation oper = additive ? Application.LoadLevelAdditiveAsync(level) : Application.LoadLevelAsync(level); #else AsyncOperation oper = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(level, additive ? LoadSceneMode.Additive : LoadSceneMode.Single); #endif OnProgress.Dispatch(oper.progress); while (!oper.isDone) { yield return(new WaitForFixedUpdate()); OnProgress.Dispatch(oper.progress); loadingScreen.OnProgress(oper.progress); } Resources.UnloadUnusedAssets(); OnLoadEnd.Dispatch(); loadingScreen.Hide(); }
public void LoadScene(string sceneName) { if (sceneName != null) { m_currentSceneName = sceneName; OnLoadStart?.Invoke(sceneName); PhotonNetwork.LoadLevel(m_currentSceneName); OnLoadEnd?.Invoke(sceneName); } }
private BaseLoadInfo ResourceLoadAsyncImp(string path, OnLoadEnd onLoadEnd) { BaseLoadInfo info = new ResourceLoadInfo(); resourceObjects.Add(path, info); info.LoadAsync(path, loadInfo => { if (loadInfo == null) { return; } if (onLoadEnd != null) { onLoadEnd(loadInfo); } }); return(info); }