private IEnumerator FinishedLoading() { Topan.Network.isMessageQueueRunning = true; if (Loader.finished != null) { Loader.finished(); Loader.finished = null; } GetComponent <AudioListener>().enabled = false; Resources.UnloadUnusedAssets(); yield return(null); GameSettings.UpdateAllReflections(); AudioListener.pause = false; RestrictionManager.restricted = false; if (loadData != "Main Menu") { while (fadeBlack.alpha < 1f) { fadeBlack.alpha = Mathf.MoveTowards(fadeBlack.alpha, 1f, Time.deltaTime * fadeSpeed); yield return(null); } } yield return(null); Shader.WarmupAllShaders(); loadData = string.Empty; isDone = true; Destroy(gameObject); }
public static void LoadLevel(string levelName) { if (levelName == "Main Menu") { Loader.finished += () => { Time.timeScale = 1f; Screen.lockCursor = false; }; } isDone = false; loadData = levelName; Application.LoadLevel("Loader"); }
private void Start() { while (ModulesToLoad[1].Count > 0) { ModuleAndAttribute temp = ModulesToLoad[1].Dequeue(); EnableModule(temp); } StringBuilder stringBuilder = new StringBuilder("Enabled Modules: "); foreach (var pair in Modules) { if (pair.Value.IsEnabled) { stringBuilder.Append($"[{pair.Key}] "); } } Logger.LogInfo(stringBuilder.ToString()); LoadConVars(); LoadConCommands(); OnFinishLoading?.Invoke(); }
public IEnumerator CallBackSync(ABLoad mAB, string url, string resname, System.Type type, ABDataType abtype) { //Debuger.Log("AssetBundleUti.CallBack " + System.IO.Path.GetFileName(url) + " " + resname + " " + type.ToString()); Count++; callbackerror = string.Empty; bCallback = true; do { if (!mAB.Create(url)) { callbackerror = "ABLoad Create Error " + url; bCallback = false; break; } yield return(StartCoroutine(mAB.Waiting())); //Debuger.Log("Waiting End "); while (true) { if (mAB.IsWWW()) { break; } yield return(null); } //Debuger.Log("Error " + mAB.Error()); if (mAB.Error()) { Debuger.LogError(mAB.GetErrorMsg()); callbackerror = mAB.GetErrorMsg(); bCallback = false; break; } else { if (typeof(AudioClip) == type) { AudioClip ac = mAB.Load(resname); //Debuger.Log(resname + " " + ac.length + " " + ac.samples + " " + ac.isReadyToPlay + " " + ac.channels); //Debuger.Log(ac.isReadyToPlay); if (ac != null) { while (true) { if (ac.isReadyToPlay) { break; } yield return(null); } ac.name = resname; mAB.Pair(resname, ac, type); // 返回 if (OnFinishLoading != null) { //Debuger.Log("AssetBundleUti.OnFinishLoading " + System.IO.Path.GetFileName(url) + " " + resname + " " + type.ToString()); OnFinishLoading(url, resname, type, true); } } else { //Debuger.LogError("Load " + resname + " in " + url); callbackerror = mAB.GetErrorMsg(); bCallback = false; break; } } else { AssetBundle ab = mAB.GetAb(); if (ab == null) { callbackerror = "AssetBundle == null"; bCallback = false; break; } AssetBundleRequest request = ab.LoadAssetAsync(resname, type); if (request == null) { callbackerror = "LoadAsync AssetBundleRequest == null"; bCallback = false; break; } while (true) { if (request.isDone) { break; } yield return(null); } mAB.Pair(resname, request.asset, type); // 返回 if (OnFinishLoading == null) { //Debuger.Log("AssetBundleUti.OnFinishLoading " + System.IO.Path.GetFileName(url) + " " + resname + " " + type.ToString()); callbackerror = "OnFinishLoading == null"; bCallback = false; break; } OnFinishLoading(url, resname, type, true); } } }while (false); if (!bCallback) { Debuger.LogError("Error " + mAB.Error() + " callbackerror: " + callbackerror); MessageBox(callbackerror + " \r\n " + OnFinishLoading.ToString()); OnFinishLoading(url, resname, type, false, callbackerror); if (mAB != null) { mAB.Dispose(); mAB = null; } } else { releaseQueue.Enqueue(mAB); } Count--; if (Count <= 0) { Count = 0; releaseAllBundles(); } }