Browse Source

预加载

guodong 1 year ago
parent
commit
1e9e6fc54f

+ 0 - 77
GameClient/Assets/Game/HotUpdate/Assets/ItemResPreloadManager.cs

@@ -1,77 +0,0 @@
-using System.Collections.Generic;
-using System;
-
-namespace GFGGame
-{
-    public enum ResType
-    {
-        Sprite,
-        Animation,
-        Both
-    }
-
-    public class ItemResPreloadManager : SingletonBase<ItemResPreloadManager>
-    {
-        public void AddSuit(int suitId, ResType resType, int[] excludeType, bool includeOptional)
-        {
-            SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
-            if (suitCfg == null)
-            {
-                return;
-            }
-            //找到要穿的散件
-            List<int> targetItemList = DressUpUtil.GetSuitItems(suitId, resType != ResType.Sprite, excludeType, includeOptional, false);
-            foreach(var itemId in targetItemList)
-            {
-                PreloadDressUpRes(itemId, resType);
-            }
-            if(resType != ResType.Sprite)
-            {
-                if(!string.IsNullOrEmpty(suitCfg.aniRes))
-                {
-                    string assetPath = ResPathUtil.GetDressUpAnimationPath(suitCfg.aniRes);
-                    PreloadManager.Instance.TryAdd(assetPath);
-                    assetPath = ResPathUtil.GetDressUpEffectPath(suitCfg.aniRes);
-                    PreloadManager.Instance.TryAdd(assetPath);
-                }
-            }
-        }
-
-        public void PreloadDressUpRes(int itemId, ResType resType = ResType.Sprite)
-        {
-            ItemCfg dressUpCfg = ItemCfgArray.Instance.GetCfg(itemId);
-            string assetPath;
-            if (resType != ResType.Animation)
-            {
-                assetPath = ResPathUtil.GetDressUpLayerSpriteResPath(dressUpCfg, 1);
-                PreloadManager.Instance.TryAdd(assetPath);
-                assetPath = ResPathUtil.GetDressUpLayerSpriteResPath(dressUpCfg, 2);
-                PreloadManager.Instance.TryAdd(assetPath);
-                assetPath = ResPathUtil.GetDressUpLayerSpriteResPath(dressUpCfg, 3);
-                PreloadManager.Instance.TryAdd(assetPath);
-            }
-            if(resType != ResType.Sprite)
-            {
-                assetPath = ResPathUtil.GetDressUpLayerAnimationResPath(dressUpCfg, 1);
-                PreloadManager.Instance.TryAdd(assetPath);
-                assetPath = ResPathUtil.GetDressUpLayerAnimationResPath(dressUpCfg, 2);
-                PreloadManager.Instance.TryAdd(assetPath);
-                assetPath = ResPathUtil.GetDressUpLayerAnimationResPath(dressUpCfg, 3);
-                PreloadManager.Instance.TryAdd(assetPath);
-                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 1);
-                PreloadManager.Instance.TryAdd(assetPath);
-                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 2);
-                PreloadManager.Instance.TryAdd(assetPath);
-                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 3);
-                PreloadManager.Instance.TryAdd(assetPath);
-            }
-        }
-
-        public void PreloadCardAnimationRes(int itemId)
-        {
-            ItemCfg cardCfg = ItemCfgArray.Instance.GetCfg(itemId);
-            string assetPath = ResPathUtil.GetCardAnimationPath(cardCfg.res);
-            PreloadManager.Instance.TryAdd(assetPath);
-        }
-    }
-}

+ 0 - 11
GameClient/Assets/Game/HotUpdate/Assets/ItemResPreloadManager.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 404804bc0fa803a4fae60c8052e54f40
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 69 - 0
GameClient/Assets/Game/HotUpdate/Assets/PreloadManager.cs

@@ -4,6 +4,13 @@ using YooAsset;
 
 
 namespace GFGGame
 namespace GFGGame
 {
 {
+    public enum ResType
+    {
+        Sprite,
+        Animation,
+        Both
+    }
+
     public class PreloadManager : SingletonMonoBase<PreloadManager>
     public class PreloadManager : SingletonMonoBase<PreloadManager>
     {
     {
         private List<string> waitList = new List<string>();
         private List<string> waitList = new List<string>();
@@ -18,6 +25,68 @@ namespace GFGGame
             LogUtil.LogEditor($"PreloadManager TryAdd {location}");
             LogUtil.LogEditor($"PreloadManager TryAdd {location}");
         }
         }
 
 
+        public void AddSuit(int suitId, ResType resType, int[] excludeType, bool includeOptional)
+        {
+            SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
+            if (suitCfg == null)
+            {
+                return;
+            }
+            //找到要穿的散件
+            List<int> targetItemList = DressUpUtil.GetSuitItems(suitId, resType != ResType.Sprite, excludeType, includeOptional, false);
+            foreach (var itemId in targetItemList)
+            {
+                PreloadDressUpRes(itemId, resType);
+            }
+            if (resType != ResType.Sprite)
+            {
+                if (!string.IsNullOrEmpty(suitCfg.aniRes))
+                {
+                    string assetPath = ResPathUtil.GetDressUpAnimationPath(suitCfg.aniRes);
+                    PreloadManager.Instance.TryAdd(assetPath);
+                    assetPath = ResPathUtil.GetDressUpEffectPath(suitCfg.aniRes);
+                    PreloadManager.Instance.TryAdd(assetPath);
+                }
+            }
+        }
+
+        public void PreloadDressUpRes(int itemId, ResType resType = ResType.Sprite)
+        {
+            ItemCfg dressUpCfg = ItemCfgArray.Instance.GetCfg(itemId);
+            string assetPath;
+            if (resType != ResType.Animation)
+            {
+                assetPath = ResPathUtil.GetDressUpLayerSpriteResPath(dressUpCfg, 1);
+                PreloadManager.Instance.TryAdd(assetPath);
+                assetPath = ResPathUtil.GetDressUpLayerSpriteResPath(dressUpCfg, 2);
+                PreloadManager.Instance.TryAdd(assetPath);
+                assetPath = ResPathUtil.GetDressUpLayerSpriteResPath(dressUpCfg, 3);
+                PreloadManager.Instance.TryAdd(assetPath);
+            }
+            if (resType != ResType.Sprite)
+            {
+                assetPath = ResPathUtil.GetDressUpLayerAnimationResPath(dressUpCfg, 1);
+                PreloadManager.Instance.TryAdd(assetPath);
+                assetPath = ResPathUtil.GetDressUpLayerAnimationResPath(dressUpCfg, 2);
+                PreloadManager.Instance.TryAdd(assetPath);
+                assetPath = ResPathUtil.GetDressUpLayerAnimationResPath(dressUpCfg, 3);
+                PreloadManager.Instance.TryAdd(assetPath);
+                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 1);
+                PreloadManager.Instance.TryAdd(assetPath);
+                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 2);
+                PreloadManager.Instance.TryAdd(assetPath);
+                assetPath = ResPathUtil.GetDressUpLayerEffectResPath(dressUpCfg, 3);
+                PreloadManager.Instance.TryAdd(assetPath);
+            }
+        }
+
+        public void PreloadCardAnimationRes(int itemId)
+        {
+            ItemCfg cardCfg = ItemCfgArray.Instance.GetCfg(itemId);
+            string assetPath = ResPathUtil.GetCardAnimationPath(cardCfg.res);
+            PreloadManager.Instance.TryAdd(assetPath);
+        }
+
         private void Update()
         private void Update()
         {
         {
             if(downloaderOperation != null)
             if(downloaderOperation != null)

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Data/CardDataManager.cs

@@ -64,7 +64,7 @@ namespace GFGGame
             _cardDicByType[cardData.mainScore][cardData.id] = cardData;
             _cardDicByType[cardData.mainScore][cardData.id] = cardData;
             if(GameGlobal.AfterDataInited)
             if(GameGlobal.AfterDataInited)
             {
             {
-                ItemResPreloadManager.Instance.PreloadCardAnimationRes(cardData.id);
+                PreloadManager.Instance.PreloadCardAnimationRes(cardData.id);
             }
             }
         }
         }
 
 

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Data/DressUpMenuItemDataManager.cs

@@ -74,7 +74,7 @@ namespace GFGGame
                 {
                 {
                     AddNewDressItem(value);
                     AddNewDressItem(value);
                     DressUpMenuSuitDataManager.CheckItemInSuit(value);
                     DressUpMenuSuitDataManager.CheckItemInSuit(value);
-                    ItemResPreloadManager.Instance.PreloadDressUpRes(value);
+                    PreloadManager.Instance.PreloadDressUpRes(value);
                 }
                 }
                 else
                 else
                 {
                 {