ソースを参照

加载状态记录

guodong 1 年間 前
コミット
65a8c02da1

+ 22 - 3
GameClient/Assets/Game/HotUpdate/Assets/LoadManager.cs

@@ -1,17 +1,30 @@
 using System.Threading.Tasks;
 using YooAsset;
+using System.Collections.Generic;
 
 namespace GFGGame
 {
     public class LoadManager : SingletonBase<LoadManager>
     {
-        public async Task CheckResExsitedAndLoad(string location)
+        private Dictionary<string, bool> checkStatusDic = new Dictionary<string, bool>();
+
+        public bool CheckResExsited(string location)
         {
-            if (string.IsNullOrEmpty(location) || !YooAssets.IsNeedDownloadFromRemote(location))
+            if (string.IsNullOrEmpty(location))
+            {
+                return false;
+            }
+            checkStatusDic.TryGetValue(location, out bool exsited);
+            return exsited;
+        }
+
+        public async Task CheckResExsitedOrDownload(string location)
+        {
+            if(CheckResExsited(location))
             {
                 return;
             }
-            var downloaderOperation = YooAssets.CreateBundleDownloader(new string[] { location}, 3, 3);
+            ResourceDownloaderOperation downloaderOperation = YooAssets.CreateBundleDownloader(new string[] { location}, 3, 3);
             if (downloaderOperation.TotalDownloadCount == 0)
             {
                 //文件已在本地,不需要下载
@@ -21,7 +34,13 @@ namespace GFGGame
             //下载
             downloaderOperation.BeginDownload();
             await downloaderOperation.Task;
+            checkStatusDic[location] = true;
             ViewManager.Hide<ModalStatusView>();
         }
+
+        public void SetResDownloaded(string location)
+        {
+            checkStatusDic[location] = true;
+        }
     }
 }

+ 26 - 8
GameClient/Assets/Game/HotUpdate/Assets/PreloadManager.cs

@@ -1,25 +1,43 @@
 using GFGGame.Launcher;
 using System.Collections.Generic;
+using YooAsset;
 
 namespace GFGGame
 {
     public class PreloadManager : SingletonMonoBase<PreloadManager>
     {
-        private Queue<string> waitQueue = new Queue<string>();
-
-        public void Init()
-        {
-
-        }
+        private List<string> waitList = new List<string>();
+        private ResourceDownloaderOperation downloaderOperation;
+        private string[] locationsLoading;
 
         public void Add(string location)
         {
-            waitQueue.Enqueue(location);
+            waitList.Add(location);
         }
 
         private void Update()
         {
-            
+            if(downloaderOperation != null)
+            {
+                if(downloaderOperation.IsDone)
+                {
+                    foreach(var t in locationsLoading)
+                    {
+                        LoadManager.Instance.SetResDownloaded(t);
+                    }
+                    downloaderOperation = null;
+                    locationsLoading = null;
+                }
+            }
+
+            if(downloaderOperation == null)
+            {
+                waitList.Reverse();//看了yooasset源码,疑似他是从后往前加载,这里翻转一下
+                locationsLoading = waitList.ToArray();
+                downloaderOperation = YooAssets.CreateBundleDownloader(locationsLoading, 1, 3);
+                downloaderOperation.BeginDownload();
+                waitList.Clear();
+            }
         }
     }
 }

+ 2 - 6
GameClient/Assets/Game/HotUpdate/Controller/GameController.cs

@@ -16,9 +16,6 @@ namespace GFGGame
             //字体
             await FontLoader.Instance.Init();
             //通用资源
-            //GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("Common"));
-            //GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("CommonGame"));
-            //GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("Main"));
             await GFGUIPackage.AddPackageAsync(ResPathUtil.GetUIPackagePath("Common"));
             await GFGUIPackage.AddPackageAsync(ResPathUtil.GetUIPackagePath("CommonGame"));
             await GFGUIPackage.AddPackageAsync(ResPathUtil.GetUIPackagePath("Main"));
@@ -50,8 +47,8 @@ namespace GFGGame
                 GameConfig.InitData(data);
                 //显示登录
                 LoginController.ShowLogin();
-                //_ = ItemCfgArray.Instance.GetAllDataAsync();
-                InitAllCfgsCache.Instance.InitAll();
+                _ = ItemCfgArray.Instance.GetAllDataAsync();
+                //InitAllCfgsCache.Instance.InitAll();
             });
         }
 
@@ -159,7 +156,6 @@ namespace GFGGame
 
         private static void EnterGame()
         {
-            LoadingView.Instance.GetUI();
 
             LoadingView.Instance.SetProgress(100, () =>
             {

+ 2 - 2
GameClient/Assets/Game/HotUpdate/DressUp/DressUpLayerOperation.cs

@@ -172,12 +172,12 @@ namespace GFGGame
         private void CheckLoadRes()
         {
             List<string> locations = new List<string>();
-            if(!string.IsNullOrEmpty(resPath) && YooAssets.IsNeedDownloadFromRemote(resPath))
+            if(!string.IsNullOrEmpty(resPath) && !LoadManager.Instance.CheckResExsited(resPath))
             {
                 //需加载
                 locations.Add(this.resPath);
             }
-            if(!string.IsNullOrEmpty(effectResPath) && YooAssets.IsNeedDownloadFromRemote(effectResPath))
+            if(!string.IsNullOrEmpty(effectResPath) && !LoadManager.Instance.CheckResExsited(effectResPath))
             {
                 //需加载
                 locations.Add(effectResPath);

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/Card/CardFosterView.cs

@@ -349,7 +349,7 @@ namespace GFGGame
                 && _cardData.star >= _cardData.itemCfg.animationCardStar 
                 && YooAssets.CheckResExist(resPath))
             {
-                await LoadManager.Instance.CheckResExsitedAndLoad(resPath);
+                await LoadManager.Instance.CheckResExsitedOrDownload(resPath);
                 _effectUI1 = new EffectUI();
                 _effectUI1.Reset(_ui.m_comCard.m_comCardHolder.m_holder, resName, resName, 100, EffectUIType.Card);
                 _ui.m_c1.selectedIndex = 1;

+ 1 - 4
GameClient/Assets/Game/HotUpdate/Views/Loading/LoadingView.cs

@@ -66,10 +66,7 @@ namespace GFGGame
         {
             base.OnHide();
         }
-        public void GetUI()
-        {
-            ET.Log.Debug("loadingui:" + _ui);
-        }
+
         /// <summary>
         /// 设置描述文字
         /// </summary>

+ 0 - 4
GameClient/Assets/Game/Launcher/Views/LauncherView.cs

@@ -62,10 +62,6 @@ namespace GFGGame
             UIPackage.RemovePackage("UI/" + _packageName + "/" + _packageName);
             _ui.Dispose(true);
             _ui = null;
-            // if (_gameObject != null)
-            // {
-            //     GameObject.Destroy(_gameObject);
-            // }
         }
         #endregion
 

+ 1 - 1
GameClient/Assets/Resources/BuildinFileManifest.asset

@@ -97,6 +97,7 @@ MonoBehaviour:
   - 6f21900325a86d8dcc902a6f7c444355.bundle
   - 70c119f57c1b2bea00aadda63ea96818.bundle
   - 70d70f1858279ea4e2c52ce3202acae3.bundle
+  - 7134261e77347e9dcb885b7c793052ed.bundle
   - 76b00fd2c9eb448eb3dd2d4ee1fc0d45.bundle
   - 77af17d5f38acde1a0df3acce1865cb5.bundle
   - 785704866a667eebe9ea70ac1db22752.bundle
@@ -119,7 +120,6 @@ MonoBehaviour:
   - 8ec7d4a076f3602ce3ab584868b1484e.bundle
   - 8ed1ea306119f690e147f0adcd53f81c.bundle
   - 8ffdedc7d1d7c6d14d3d34af723bef3c.bundle
-  - 90f65649df6d2742dfd89ba344059503.bundle
   - 91065e88658cf678338ae089caa347d0.bundle
   - 9196b7570c8a062583a7101e3476a8ec.bundle
   - 970a9b4507f476f11c7a01f310696f80.bundle