コード例 #1
0
        IEnumerator LoadGameBaseModule()
        {
            bool succeed = true;

            if (AssetLoaderManager.Instance().HasSmallUpdate)
            {
                yield return(AssetBundleManager.Instance().LoadAssetBundleFromPkg(mBundleName, null,
                                                                                  () =>
                {
                    succeed = false;
                }));

                if (!succeed)
                {
                    mError = GMError.GME_LoadBaseModuleFailed;
                    LoggerManager.Instance().LogErrorFormat("Load BaseBundle {0} From Pkg Failed ...", mBundleName);
                    yield break;
                }
            }
            else
            {
                yield return(AssetBundleManager.Instance().LoadAssetBundle(mBundleName, null,
                                                                           () =>
                {
                    succeed = false;
                }, true));


                if (!succeed)
                {
                    mError = GMError.GME_LoadBaseModuleFailed;
                    LoggerManager.Instance().LogErrorFormat("Load BaseBundle {0} From StreamingAssets Failed ...", mBundleName);
                    yield break;
                }
            }

            TableManager.Instance().LoadTableFromAssetBundle <ProtoTable.ModuleTable>(AssetBundleManager.Instance().getAssetBundle(mBundleName));
            var moduleTable = TableManager.Instance().GetTable <ProtoTable.ModuleTable>();

            if (null == moduleTable)
            {
                mError = GMError.GME_LoadBaseModuleFailed;
                LoggerManager.Instance().LogErrorFormat("load ModuleTable Failed ...");
                yield break;
            }
            LoggerManager.Instance().LogProcessFormat("Load ModuleTable Succeed !");

            yield return(AssetBundleManager.Instance().LoadAssetBundleFromModule(1, null, () =>
            {
                succeed = false;
            }));

            if (!succeed)
            {
                mError = GMError.GME_LoadBaseModuleFailed;
                LoggerManager.Instance().LogErrorFormat("load baseModule Failed ...");
                yield break;
            }

            TableManager.Instance().LoadTableFromAssetBundle <ProtoTable.ResourceInfoTable>(AssetBundleManager.Instance().getAssetBundle(mBundleName));
            var localResourcesInfoTable = TableManager.Instance().GetTable <ProtoTable.ResourceInfoTable>();

            if (null == localResourcesInfoTable)
            {
                mError = GMError.GME_LoadBaseModuleFailed;
                LoggerManager.Instance().LogErrorFormat("加载游戏资源表失败...");
                yield break;
            }

            TableManager.Instance().LoadTableFromAssetBundle <ProtoTable.FrameTypeTable>(AssetBundleManager.Instance().getAssetBundle(mBundleName));
            var frameTypeTable = TableManager.Instance().GetTable <ProtoTable.FrameTypeTable>();

            if (null == frameTypeTable)
            {
                mError = GMError.GME_LoadBaseModuleFailed;
                LoggerManager.Instance().LogErrorFormat("加载界面表失败...");
                yield break;
            }

            var resourceInfoTable = AssetLoaderManager.Instance().Initialize(new AssetLoaderData
            {
                frameHandle             = this,
                localResourcesInfoTable = localResourcesInfoTable,
            });
        }
コード例 #2
0
        IEnumerator DownLoadBaseModule()
        {
            bool succeed = true;

            var baseBundleUrl = string.Format("{0}{1}/{2}/", mBaseConfigUrl, CommonFunction.getPlatformString(),
                                              AssetLoaderManager.Instance().RemoteVersion);

            yield return(AssetBundleManager.Instance().DownLoadAssetBundles(baseBundleUrl, new List <string>()
            {
                mBundleName
            }, null, () =>
            {
                succeed = false;
            }));

            if (!succeed)
            {
                mError = GMError.GME_DownLoadBaseModuleFailed;
                LoggerManager.Instance().LogErrorFormat("从远程加载[{0}] Bundle 失败 !!!", mBundleName);
                yield break;
            }

            yield return(AssetBundleManager.Instance().LoadAssetBundle(mBundleName, null, () =>
            {
                succeed = false;
            }, false));

            if (!succeed)
            {
                mError = GMError.GME_DownLoadBaseModuleFailed;
                LoggerManager.Instance().LogErrorFormat("从本地加载 刚下载的[{0}] Bundle 失败 !!!", mBundleName);
                yield break;
            }

            var baseBundle = AssetBundleManager.Instance().getAssetBundle(mBundleName);

            if (null == baseBundle)
            {
                mError = GMError.GME_DownLoadBaseModuleFailed;
                LoggerManager.Instance().LogFormat("加载[{0}] Bundle 失败 !!!", mBundleName);
                yield break;
            }

            //加载模块表
            TableManager.Instance().LoadTableFromAssetBundle <ProtoTable.ModuleTable>(baseBundle);
            var moduleTable = TableManager.Instance().GetTable <ModuleTable>();

            if (null == moduleTable)
            {
                mError = GMError.GME_DownLoadBaseModuleFailed;
                LoggerManager.Instance().LogErrorFormat("加载模块表 ModuleTable 失败 !!!");
                yield break;
            }

            //加载
            int baseModuleId = 1;
            var moduleItem   = TableManager.Instance().GetTableItem <ModuleTable>(baseModuleId);

            if (null == moduleTable)
            {
                mError = GMError.GME_DownLoadBaseModuleFailed;
                LoggerManager.Instance().LogErrorFormat("加载模块表项 ModuleTable 失败 ID={0}!!!", baseModuleId);
                yield break;
            }

            List <string> needDownLoadBundles = new List <string>(32);

            AssetLoaderManager.Instance().GetNeedDownLoadModule(moduleItem.RequiredBundles.ToArray(), needDownLoadBundles);
            AssetLoaderManager.Instance().GetNeedDownLoadModule(new string[]
            {
                CommonFunction.getPlatformString()
            }, needDownLoadBundles);

            AssetBundleManager.Instance().UnLoadAssetBundle(mBundleName);

            if (needDownLoadBundles.Count > 0)
            {
                for (int i = 0; i < needDownLoadBundles.Count; ++i)
                {
                    LoggerManager.Instance().LogProcessFormat("Bundle [{0}] 需要下载 ...", needDownLoadBundles[i]);
                }

                var bundleUrl = string.Format("{0}{1}/{2}/", mBaseConfigUrl, CommonFunction.getPlatformString(),
                                              AssetLoaderManager.Instance().RemoteVersion);

                yield return(AssetBundleManager.Instance().DownLoadAssetBundles(bundleUrl, needDownLoadBundles, null, () =>
                {
                    succeed = false;
                    LoggerManager.Instance().LogErrorFormat("DownLoadAssetBundles Failed ...");
                }));

                if (!succeed)
                {
                    mError = GMError.GME_DownLoadBaseModuleFailed;
                    yield break;
                }
                LoggerManager.Instance().LogFormat("DownLoadBaseModule Succeed !");
            }
            else
            {
                LoggerManager.Instance().LogProcessFormat("No Bundle Need Download ...");
            }
        }