浏览代码

摘星报错处理和回收特效优化

huangxiaoyue 2 年之前
父节点
当前提交
ad7c277c4f

+ 2 - 5
GameClient/Assets/Game/HotUpdate/Views/LuckyBox/LuckyBoxBonusShowView.cs

@@ -12,8 +12,7 @@ namespace GFGGame
         private List<ItemData> _rewardList = new List<ItemData>();
         // private List<GameObject> _gameobjects = new List<GameObject>();
         //private Dictionary<int, Dictionary<int, EffectUI>> _effList = new Dictionary<int, Dictionary<int, EffectUI>>();
-        private Dictionary<int, EffectUI> _effList = new Dictionary<int, EffectUI>();
-        private int countEff = 0;
+        private List<EffectUI> _effList = new List<EffectUI>();
 
         private EffectUI _effectUI1;
         private EffectUI _effectUI2;
@@ -90,7 +89,6 @@ namespace GFGGame
                 EffectUIPool.Recycle(_effList[key]);
                 _effList[key] = null;
             }
-            countEff = 0;
             _effList.Clear();
         
             EffectUIPool.Recycle(_effectUI4);
@@ -118,8 +116,7 @@ namespace GFGGame
             {
                 GGraph holder = itemCfg.rarity == 3 ? item.m_comIcon.m_holder : item.m_comIcon.m_holder1;
                 EffectUI _effectUI = EffectUIPool.CreateEffectUI(holder, "ui_LuckyBox", resPath);
-                _effList.Add(countEff , _effectUI);
-                countEff += 1;
+                _effList.Add(_effectUI);
             }
             if (countType == 1 && itemCfg.rarity > 2 && _effectUI4 == null)
             {

+ 12 - 18
GameClient/Assets/Game/HotUpdate/Views/LuckyBox/LuckyBoxStarView.cs

@@ -21,7 +21,7 @@ namespace GFGGame
         // private List<GoWrapper> _wrappers = new List<GoWrapper>();
         // private List<GameObject> _gameObjects1 = new List<GameObject>();
         // private List<GoWrapper> _wrappers1 = new List<GoWrapper>();
-        private Dictionary<int, List<EffectUI>> dicEffect = new Dictionary<int, List<EffectUI>>();
+        private List<EffectUI> dicEffect = new List<EffectUI>();
         private List<EffectUI> effObj = new List<EffectUI>();
         private EffectUI _effectUI1;
         private EffectUI _effectUI2;
@@ -61,30 +61,27 @@ namespace GFGGame
                 for (int i = comStar.target.numChildren - 1; i >= 0; i--)
                 {
                     if (comStar.target.GetChildAt(i).name == "comLine") continue;
-                    comStar.target.RemoveChildAt(i);
+                    var starchild = comStar.target.RemoveChildAt(i);
+                    starchild.Dispose();
                 }
                 index++;
                 star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
                 UI_ComStar.ProxyEnd();
             }
-            foreach (int key in dicEffect.Keys)
+            for (int i = 0; i < dicEffect.Count; i++)
             {
-                List<EffectUI> value = dicEffect[key];
-                for (int i = 0; i < value.Count; i++)
-                {
-                    EffectUIPool.Recycle(value[i]);
-                    value[i] = null;
-                }
+                EffectUIPool.Recycle(dicEffect[i]);
+                dicEffect[i] = null;
             }
             for (int i = 0; i < effObj.Count; i++)
             {
                 EffectUIPool.Recycle(effObj[i]);
                 effObj[i] = null;
             }
-
             notClickComStars.Clear();
             clickComStars.Clear();
             dicEffect.Clear();
+            effObj.Clear();
 
             Timers.inst.Remove(CheckGuide);
             Debug.Log("OnHide  LuckyBoxStarView");
@@ -132,11 +129,13 @@ namespace GFGGame
             showGuide = GuideDataManager.IsGuideFinish(ConstGuideId.LUCKY_BOX_LINE) <= 0;
 
             curComStar = null;
+            for (int i = 0; i < comStars.Count; i++) {
+                comStars.RemoveAt(i);
+            }
             comStars.Clear();
             int index = 0;
             GObject star = _ui.target.GetChild(string.Format("comStar{0}_{1}_{2}", _ui.m_ctrlBuyType.selectedIndex, _ui.m_ctrlRewardsType.selectedIndex, index));
 
-
             while (star != null && star.visible == true)
             {
                 UI_ComStar comStar = UI_ComStar.Proxy(star);
@@ -179,12 +178,8 @@ namespace GFGGame
             else
             {
                 gcom = UIPackage.CreateObject("LuckyBox", "ComHolder").asCom;
-                EffectUI _effectUI1 = EffectUIPool.CreateEffectUI(gcom.GetChild("holder").asGraph, "ui_LuckyBox", name);
-                if (!dicEffect.ContainsKey(index))
-                {
-                    dicEffect.Add(index, new List<EffectUI>());
-                }
-                dicEffect[index].Add(_effectUI1);
+                EffectUI _effectUI = EffectUIPool.CreateEffectUI(gcom.GetChild("holder").asGraph, "ui_LuckyBox", name);
+                dicEffect.Add(_effectUI);
             }
             return gcom;
         }
@@ -225,7 +220,6 @@ namespace GFGGame
                     // comStar.target.GetChildAt(1).asCom.visible = false;
                     string resPath = _isLuckyBox ? "LINE_Bule" : "LINE";
                     EffectUI _effectUI = EffectUIPool.CreateEffectUI(comStar.m_comLine.m_holder, "ui_LuckyBox", resPath);
-
                     effObj.Add(_effectUI);
                     UI_ComStar.ProxyEnd();