Example #1
0
    IEnumerator DelayLoadScene()
    {
        yield return(null);

        var watchReport = new BTickWatcher();

        EventLogReport.Instance.ReportEvent(EventLogType.event_start_enter_game);

        InitCustomAbVfs();

        if (!AssetBundleLoader.Instance.Init(true))
        {
            EventLogReport.Instance.ReportEvent(EventLogType.event_fail_enter_game, "AssetBundleLoader.Init failed");

            BLogger.Error("AssetBundleLoader init failed");
            ShowText("进入游戏失败(资源错误)");
            yield break;
        }

        //读取缓存策略
        LoadAbCacheConfig();

        SceneAssetLoader loader = SceneAssetLoader.Instance;
        var watchStep           = new BTickWatcher();

        float preloadConfigPercent = 0.3f;

        EventLogReport.Instance.ReportEvent(EventLogType.event_preload_config, watchStep.ElapseTime());
        watchStep.Refresh();

        float currPercent = preloadConfigPercent;

        yield return(AssetBundleLoader.Instance.StartCoroutine(UnitySceneLoader.LoadSceneAsync(m_startScene,
                                                                                               (progress) =>
        {
            float actualProgress = currPercent + (1.0f - currPercent) * progress;
            int currProgress = (int)(actualProgress * 100);
            if (m_title != null)
            {
                m_title.text = StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_GAME_ETNERING) +
                               currProgress.ToString() + "%";
                SetProgress((uint)currProgress, 100);
            }

            BLogger.Info("scene loading process:{0}", currProgress);
        }, null)));

        EventLogReport.Instance.ReportEvent(EventLogType.event_load_scene0, watchStep.ElapseTime());
        watchStep.Refresh();

        if (loader.haveError)
        {
            ShowConfirm(StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_ENTER_GAME_FAILED,
                                                              loader.lastError), false, DodLib.DoQuit);
            yield break;
        }

        EventLogReport.Instance.ReportEvent(EventLogType.event_end_enter_game, watchReport.ElapseTime());
    }
Example #2
0
 public void LoadSceneAsync(string sceneName, Action <float> sceneProgress, Action onLoaded)
 {
     ResourceInst.Instance.StartCoroutine(UnitySceneLoader.LoadSceneAsync(sceneName, sceneProgress, onLoaded));
 }
Example #3
0
 public void LoadScene(string sceneName, bool persist)
 {
     UnitySceneLoader.LoadScene(sceneName, persist);
 }