IEnumerator LoadScenes(NetResult result) { yield return(Service.Run(DownloadSceneMeta(result))); if (result.IsFailed()) { logger.LogError("Can not load scene meta."); yield break; } #if UNITY_EDITOR && BOOT_BUNDLE_EDIT yield break; #endif // init count doneCount = 0; string text = Service.sb.Get("loading.status.bundle.load.scene"); if (presenter != null) { presenter.SetDescription(string.Format(text, 0)); } successSceneWorkerCount = 0; failedSceneWorkerCount = 0; for (int index = 0; index < worker; index++) { Service.Run(LoadSceneWorker(index)); } // waiting load while (true) { yield return(new WaitForSeconds(0.1f)); if (successSceneWorkerCount + failedSceneWorkerCount < worker) { continue; } break; } // result check if (failedSceneWorkerCount > 0) { result.SetSuccess(false); } else { result.SetSuccess(true); PersistenceUtil.SaveTextFile(remoteScenesMetaFilePath, remoteScenesMeta); } }
public IEnumerator Initialize(BundleLoadingPresenter presenter, string cdnHost, NetResult result) { this.presenter = presenter; this.cdnHost = cdnHost; this.ready = false; Service.Run(UpdateProgress()); yield return(Service.Run(LoadScenes(result))); if (result.IsFailed()) { yield break; } yield return(Service.Run(LoadResources(result))); if (result.IsFailed()) { yield break; } result.SetSuccess(true); ready = true; yield break; }
IEnumerator DownloadSceneMeta(NetResult result) { // get local string localMeta = PersistenceUtil.LoadTextFile(remoteScenesMetaFilePath); if (localMeta.Length > 0) { try { localScenes = JsonMapper.ToObject <Dictionary <string, uint> >(localMeta); } catch (Exception e) { logger.LogWarning(e.ToString()); } } // get remote using (WWW www = new WWW(cdnScenesMeta)) { yield return(www); if (www.error != null) { result.SetSuccess(false); yield break; } try { remoteScenes = JsonMapper.ToObject <Dictionary <string, uint> >(www.text); remoteScenesMeta = www.text; result.SetSuccess(true); } catch (Exception e) { result.SetSuccess(false); logger.LogError(e.ToString()); } } }