示例#1
0
        public static async Task DownloadBundle()
        {
            if (Define.IsAsync)
            {
                try
                {
                    using (BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.AddComponent <BundleDownloaderComponent>())
                    {
                        // 下载Version进行MD5对比
                        await bundleDownloaderComponent.StartAsync();

                        // 根据对比结果进行自动下载更新
                        await bundleDownloaderComponent.DownloadAsync();
                    }
                    // 下载成功后读取AssetBundleManifest数据并且缓存起来
                    Game.Scene.GetComponent <ResourcesComponent>().LoadOneBundle("StreamingAssets");
                    ResourcesComponent.AssetBundleManifestObject = (AssetBundleManifest)Game.Scene.GetComponent <ResourcesComponent>().GetAsset("StreamingAssets", "AssetBundleManifest");

                    // 完成更新
                    FGUI.GetShowingUI <UI_CheckUpdate>()?.SetState(DownloadState.Done);
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
            else
            {
                // 编辑器模式直接跳到完成
                FGUI.GetShowingUI <UI_CheckUpdate>()?.SetState(DownloadState.Done);
            }
        }
示例#2
0
        public static async ETTask DownloadBundle()
        {
            if (Define.IsAsync)
            {
#if true
                try
                {
                    using (BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.AddComponent <BundleDownloaderComponent>())
                    {
                        await bundleDownloaderComponent.StartAsync();

                        Game.EventSystem.Run(EventIdType.LoadingBegin);

                        await bundleDownloaderComponent.DownloadAsync();
                    }

                    Game.EventSystem.Run(EventIdType.LoadingFinish);
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
#endif

#if !UNITY_EDITOR
                Game.Scene.GetComponent <ResourcesComponent>().LoadOneBundle("StreamingAssets");
                ResourcesComponent.AssetBundleManifestObject = (AssetBundleManifest)Game.Scene.GetComponent <ResourcesComponent>().GetAsset("StreamingAssets", "AssetBundleManifest");
#endif
            }

            await ETTask.CompletedTask;
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static async ETTask DownloadBundle()
        {
            //通过预定义符判断是否是异步下载
            if (Define.IsAsync)
            {
                try
                {
                    //获取AssetsBudle下载组件,从web端下载,并对比md5码,对比资源
                    using (BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.AddComponent <BundleDownloaderComponent>())
                    {
                        //拿到远程和本地所有不需要热更的bundle
                        await bundleDownloaderComponent.StartAsync();

                        //通过事件系统调用显示加载界面
                        Game.EventSystem.Run(EventIdType.LoadingBegin);

                        await bundleDownloaderComponent.DownloadAsync();
                    }

                    Game.EventSystem.Run(EventIdType.LoadingFinish);

                    Game.Scene.GetComponent <ResourcesComponent>().LoadOneBundle("StreamingAssets");
                    ResourcesComponent.AssetBundleManifestObject = (AssetBundleManifest)Game.Scene.GetComponent <ResourcesComponent>().GetAsset("StreamingAssets", "AssetBundleManifest");
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
示例#4
0
        public static async ETTask DownloadBundle()
        {
            if (!Define.UseEditorResouces)
            {
                try
                {
                    using (BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.AddComponent <BundleDownloaderComponent>())
                    {
                        await bundleDownloaderComponent.StartAsync();

                        Game.EventSystem.Run(EventIdType.LoadingBegin);


                        return;

                        await bundleDownloaderComponent.DownloadAsync();

                        var loadingCpt = Game.Scene.GetComponent <UIComponent>().Get(UIType.InitLoadingUI)?.GetComponent <UILoadingComponent>();
                        if (loadingCpt != null)
                        {
                            loadingCpt.TargetValue = 1;
                        }
                    }
                    //                    Game.EventSystem.Run(EventIdType.LoadingFinish);
                    //Debug.LogError("xxx");
                    Game.Scene.GetComponent <ResourcesComponent>().LoadOneBundle("StreamingAssets");
                    ResourcesComponent.AssetBundleManifestObject = (AssetBundleManifest)Game.Scene.GetComponent <ResourcesComponent>().GetAsset("StreamingAssets", "AssetBundleManifest");
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
示例#5
0
        /// <summary>
        /// 下载资源信息(编辑器模式下不会运行)
        /// </summary>
        /// <returns></returns>
        public static async ETTask DownloadBundle()
        {
            if (Define.IsAsync)
            {
                try
                {
                    using (BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.AddComponent <BundleDownloaderComponent>())
                    {
                        await bundleDownloaderComponent.StartAsync();

                        Log.Debug("运行 登录开始");
                        Game.EventSystem.Run(EventIdType.LoadingBegin);

                        await bundleDownloaderComponent.DownloadAsync();
                    }
                    Game.EventSystem.Run(EventIdType.LoadingFinish);

                    Game.Scene.GetComponent <ResourcesComponent>().LoadOneBundle("StreamingAssets");

                    ResourcesComponent.AssetBundleManifestObject = (AssetBundleManifest)Game.Scene.GetComponent <ResourcesComponent>().GetAsset("StreamingAssets", "AssetBundleManifest");
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
示例#6
0
        private async ETTask HotfixUpdate()
        {
            BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.GetComponent <BundleDownloaderComponent>();

            for (int i = 0; i < GameVersionsConfigMgr.Ins.ServerGameVersionsConfig.ToyGameVersionsArray.Count; i++)
            {
                for (int j = 0; j < GameVersionsConfigMgr.Ins.LocalGameVersionsConfig.ToyGameVersionsArray.Count; j++)
                {
                    //对比服务器版本
                    if (GameVersionsConfigMgr.Ins.ServerGameVersionsConfig.ToyGameVersionsArray[i].Id ==
                        GameVersionsConfigMgr.Ins.LocalGameVersionsConfig.ToyGameVersionsArray[j].Id)
                    {
                        //如果本地版本比服务器版本 高或者相同 就不用更新
                        if (GameVersionsConfigMgr.Ins.LocalGameVersionsConfig.ToyGameVersionsArray[j].Version >=
                            GameVersionsConfigMgr.Ins.ServerGameVersionsConfig.ToyGameVersionsArray[i].Version)
                        {
                            continue;
                        }
                        BundleDownSchedule bundleDownSchedule = new BundleDownSchedule();
                        UndateResActionInvoke(bundleDownSchedule, i + 1, GameVersionsConfigMgr.Ins.ServerGameVersionsConfig.ToyGameVersionsArray.Count);
                        await bundleDownloaderComponent.StartAsync(GameVersionsConfigMgr.Ins.ServerGameVersionsConfig
                                                                   .ToyGameVersionsArray[i], bundleDownSchedule);
                    }
                }
            }
            GameVersionsConfigMgr.Ins.SaveServerVersionsToLocal(); //更新完成 存储服务器版本信息到本地
        }
示例#7
0
        public static async ETTask DownloadBundle()
        {
            if (Define.IsAsync)
            {
                try
                {
                    using (BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.
                                                                                 AddComponent <BundleDownloaderComponent>())
                    {
                        //跟远程对比 确认哪些文件需要进行更新 压入待更新的队列中
                        await bundleDownloaderComponent.StartAsync();

                        //派发进行开始加载的事件
                        Game.EventSystem.Run(EventIdType.LoadingBegin);

                        //就是从队列里取出要下载的文件信息 然后进行下载
                        await bundleDownloaderComponent.DownloadAsync();
                    }

                    Game.EventSystem.Run(EventIdType.LoadingFinish);
                    //以往记录所有AB信息的AB包 都是以平台名称定义的 那是因为父目录是以平台名称进行定义
                    //而ET中,AB文件存放的父目录是StreamingAssets 而非平台名称
                    //所以无论什么平台,记录所有AB信息的文件都叫StreamingAssets
                    Game.Scene.GetComponent <ResourcesComponent>().LoadOneBundle("StreamingAssets");
                    //缓存分析依赖的Mainifest文件
                    ResourcesComponent.AssetBundleManifestObject = (AssetBundleManifest)Game.Scene
                                                                   .GetComponent <ResourcesComponent>().GetAsset("StreamingAssets", "AssetBundleManifest");
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
示例#8
0
        /// <summary>
        /// 下载AB包
        /// </summary>
        /// <returns></returns>
        public static async Task DownloadBundle()
        {
            if (Define.IsAsync)             //如果不是在编辑器模式下
            {
                try
                {
                    using (BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.AddComponent <BundleDownloaderComponent>())
                    {
                        await bundleDownloaderComponent.StartAsync();    //确认需要更新的AB包

                        Game.EventSystem.Run(EventIdType.LoadingBegin);  //发出开始加载事件消息

                        await bundleDownloaderComponent.DownloadAsync(); //开始下载AB包
                    }

                    Game.EventSystem.Run(EventIdType.LoadingFinish);                     //发出加载完成事件消息
                    //同步加载StreamingAssets ab包
                    Game.Scene.GetComponent <ResourcesComponent>().LoadOneBundle("StreamingAssets");
                    //拿到StreamingAssets ab包的依赖文件AssetBundleManifest
                    ResourcesComponent.AssetBundleManifestObject = (AssetBundleManifest)Game.Scene.GetComponent <ResourcesComponent>().GetAsset("StreamingAssets", "AssetBundleManifest");
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
示例#9
0
 public static async Task CheckDownloadBundle()
 {
     if (Define.IsAsync)
     {
         try
         {
             using (BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.GetComponent <BundleDownloaderComponent>() ?? Game.Scene.AddComponent <BundleDownloaderComponent>())
             {
                 await bundleDownloaderComponent.StartAsync();
             }
         }
         catch (Exception e)
         {
             Log.Error(e);
         }
     }
 }
示例#10
0
 public static async Task StartDownLoadResources()
 {
     if (Define.IsAsync)
     {
         try
         {
             using (BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.AddComponent <BundleDownloaderComponent>())
             {
                 await bundleDownloaderComponent.StartAsync();
             }
             Game.Scene.GetComponent <ResourcesComponent>().LoadOneBundle("StreamingAssets");
             ResourcesComponent.AssetBundleManifestObject = Game.Scene.GetComponent <ResourcesComponent>().GetAsset <AssetBundleManifest>("StreamingAssets", "AssetBundleManifest");
         }
         catch (Exception e)
         {
             Log.Error(e.ToString());
         }
     }
 }