Пример #1
0
    IEnumerator CrtUpdateFromRepairClient()
    {
        AssetUpdater updater = AssetUpdater.Instance;

        yield return(StartCoroutine(updater.CheckUpdate(true, this)));

        StopTickTitle();

        AssetVerInfo svrVerInfo = updater.svrVerInfo;

        if (svrVerInfo == null)
        {
            ShowConfirm(
                StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_CHECK_VERSION_FAILED,
                                                      AssetVersionMgr.Instance.error), false, RetryUpdate);
            yield break;
        }

        ///读取本地
        AssetVersionMgr.Instance.LoadLocalAllAssetMd5();

        //获取更新的大小
        StartTickTitle(StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_CHECK_UPDATE_CONTENT));
        yield return(StartCoroutine(AssetVersionMgr.Instance.DownloadLatestIndex(svrVerInfo.m_assetUrl)));

        //yield return StartCoroutine(AssetVersionMgr.Instance);
        StopTickTitle();

        if (AssetVersionMgr.Instance.haveErr)
        {
            ShowConfirm(StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_CHECK_UPDATE_CONTENT_FAILED,
                                                              AssetVersionMgr.Instance.error), false, RetryUpdate);
            yield break;
        }

        ShowConfirm(StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_ASSET_UPDATE_INFO,
                                                          AssetVersionMgr.Instance.GetUpdateFileCount(), GetDataSize(AssetVersionMgr.Instance.GetToUpdateSize())), true,
                    OnUpdateConfirmOK, OnUpdateConfirmCancel);
    }
Пример #2
0
    /// <summary>
    /// 准备预处理AB资源,从jar文件挪到data目录
    /// </summary>
    /// <returns></returns>
    IEnumerator GameStartup()
    {
        //m_process.gameObject.SetActive(false);
        AssetBundlePrepare abPrepare = AssetBundlePrepare.Instance;

        ShowText(StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_GAME_ETNERING));
        m_labelVersion.text = "";

        yield return(StartCoroutine(abPrepare.CheckNeedPrepare()));

        ShowText(StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_GAME_ETNERING));

        if (BaseConfigInfo.enableObbSplitMode)
        {
            if (ObbMgr.Instance.IsNeedDownloadObb())
            {
                SceneManager.LoadScene("Scene_obbdownload");
                yield break;
            }
        }

        var isReportPrepareEvent = false;
        var watchReport          = new BTickWatcher();

        if (!abPrepare.IsHaveErr() && abPrepare.NeedPrepare)
        {
            EventLogReport.Instance.ReportEvent(EventLogType.event_start_unpack);
            isReportPrepareEvent = true;
        }

        yield return(StartCoroutine(abPrepare.StartPrepareAb(this)));

        if (abPrepare.IsHaveErr())
        {
            if (isReportPrepareEvent)
            {
                EventLogReport.Instance.ReportEvent(EventLogType.event_fail_unpack, abPrepare.error);
            }

            ShowConfirm(StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_PREPARE_FAILED, abPrepare.error), false,
                        DodLib.DoQuit);
            yield break;
        }

        if (isReportPrepareEvent)
        {
            EventLogReport.Instance.ReportEvent(EventLogType.event_end_unpack, watchReport.ElapseTime());
        }

        ///开始检测版本
        AssetVersionMgr.Instance.ReadBaseInfo();

        if (AssetVersionMgr.Instance.haveErr)
        {
            ShowConfirm(
                StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_ASSETVER_INIT_FAILED,
                                                      AssetVersionMgr.Instance.error), false,
                DodLib.DoQuit);
            yield break;
        }

        DBugly.Init(BaseConfigInfo.PlatformName, AssetVersionMgr.Instance.assetVersion);

//         //统计检查版本成功还是失败
//         PlatformUtil.StatisticsEventBegin("boot_update");

        //获取版本号
        string version = AssetVersionMgr.Instance.assetVersion;

        m_labelVersion.text = StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_VERSION_INFO, version);

        StartTickTitle(StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_CHECK_UPDATE));
        AssetUpdater updater = AssetUpdater.Instance;

        yield return(StartCoroutine(updater.CheckUpdate(false, this)));

        StopTickTitle();

        AssetVerInfo svrVerInfo = updater.svrVerInfo;

        if (svrVerInfo == null)
        {
//             PlatformUtil.StatisticsEventFailed("boot_update", "network");
            ShowConfirm(
                StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_CHECK_VERSION_FAILED,
                                                      AssetVersionMgr.Instance.error), false, RetryUpdate);
            yield break;
        }

//         PlatformUtil.StatisticsEventEnd("boot_update");

        if (svrVerInfo.m_updateType == AssetUpdateType.UPDATE_NONE)
        {
            StartEnterGameScene();
        }
        else if (svrVerInfo.m_updateType == AssetUpdateType.UPDATE_ASSET)
        {
            ///读取本地
            AssetVersionMgr.Instance.LoadLocalAllAssetMd5();

            //获取更新的大小
            StartTickTitle(StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_CHECK_UPDATE_CONTENT));
            yield return(StartCoroutine(AssetVersionMgr.Instance.DownloadLatestIndex(svrVerInfo.m_assetUrl)));

            yield return(StartCoroutine(AssetVersionMgr.Instance.BeginUpdateIndex(svrVerInfo.m_assetUrl)));

            StopTickTitle();

            if (AssetVersionMgr.Instance.haveErr)
            {
                ShowConfirm(StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_CHECK_UPDATE_CONTENT_FAILED,
                                                                  AssetVersionMgr.Instance.error), false, RetryUpdate);
                yield break;
            }
#if !UNITY_EDITOR
            if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
            {
                //直接下载
                OnUpdateConfirmOK();
            }
            else
#endif
            ShowConfirm(StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_ASSET_UPDATE_INFO,
                                                              AssetVersionMgr.Instance.GetUpdateFileCount(), GetDataSize(AssetVersionMgr.Instance.GetToUpdateSize())), true,
                        OnUpdateConfirmOK, OnUpdateConfirmCancel);
        }
        else if (svrVerInfo.m_updateType == AssetUpdateType.UPDATE_PROGRAME)
        {
            if (string.IsNullOrEmpty(svrVerInfo.m_help))
            {
                ShowConfirm(svrVerInfo.m_err, true,
                            OnUpdateConfirmOK, OnUpdateConfirmCancel);
            }
            else
            {
                ShowConfirmIos(svrVerInfo.m_err, OnUpdateConfirmOK, () =>
                {
                    Application.OpenURL(svrVerInfo.m_help);
                });
            }
        }
        else if (svrVerInfo.m_updateType == AssetUpdateType.UPDATE_ERROR)
        {
            ShowText(svrVerInfo.m_err);
        }
        else
        {
            ShowText(StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_CHECK_UPDATE_JSON_DETAIL,
                                                           svrVerInfo.m_updateType));
        }
    }