Untitled
plain_text
2 months ago
2.3 kB
1
Indexable
Never
private IEnumerator LoadScenes() { var firstOpen = PlayerPrefs.GetInt("FirstOpen", 0); if (firstOpen == 0) { ByteBrew.NewCustomEvent("first_open"); PlayerPrefs.SetInt("FirstOpen", 1); } //- load 2 scenes in 1 frame to make sure all static classes and variables //- were created before using // SceneManager.LoadScene(SceneGameManager.Instance._sceneCityId); //- rem load 2 scenes //SceneManager.LoadScene(_sceneGameplay, LoadSceneMode.Single); yield return null; operation = SceneManager.LoadSceneAsync(_sceneGameplay); operation.allowSceneActivation = false; while (operation.progress < 0.89f) { yield return null; } if (!_isFinishRemoteConfig) { DOVirtual.DelayedCall(4, () => { UnityLog.LogI("Loader: Remote Config load time out 4s"); _isFinishRemoteConfig = true; }); } yield return new WaitUntil(() => _isFinishLoadBundle); yield return new WaitUntil(() => _isFinishRemoteConfig); fill.DOSizeDelta(new Vector2(625, 8), 1f).OnComplete(() => { // _carPunch.Kill(); }); yield return new WaitForSeconds(1); UnityLog.LogI("Loader: Finish load go to gameplay"); AdsManager.InitModules(); yield return null; operation.allowSceneActivation = true; // while (!operation.is) // { // yield return null; // } //Block when loading complete automatic switching //@tuan: try to fix in case lagging dont show scene in game -> stuck at logo yield return null; // SceneGameManager.Instance.SceneCity.SetVisibleScene(false); //- rem load 2 scenes // SceneManager.SetActiveScene(SceneManager.GetSceneByName(_sceneGameplay)); // yield return null; //SceneGameManager.Instance.SetVisibleCameraMain(true); }