Browse Source

摘星楼特效报错问题

huangxiaoyue 2 years ago
parent
commit
e1ecc9fe47

+ 11 - 13
GameClient/Assets/Game/HotUpdate/Views/LuckyBox/LuckyBoxBonusShowView.cs

@@ -11,8 +11,7 @@ namespace GFGGame
         private UI_LuckBoxBonusShowUI _ui;
         private List<ItemData> _rewardList = new List<ItemData>();
         // private List<GameObject> _gameobjects = new List<GameObject>();
-        private Dictionary<int, Dictionary<int, GameObject>> _gameobjects = new Dictionary<int, Dictionary<int, GameObject>>();
-        private Dictionary<int, Dictionary<int, GoWrapper>> _wrappers = new Dictionary<int, Dictionary<int, GoWrapper>>();
+        private Dictionary<int, Dictionary<int, EffectUI>> _effList = new Dictionary<int, Dictionary<int, EffectUI>>();
 
         private EffectUI _effectUI1;
         private EffectUI _effectUI2;
@@ -28,13 +27,15 @@ namespace GFGGame
             //     SceneController.DestroyObjectFromView(_gameobjects[i], _wrappers[i]);
 
             // }
-            foreach (int key in _gameobjects.Keys)
+            foreach (int key in _effList.Keys)
             {
-                foreach (int key1 in _gameobjects[key].Keys)
+                foreach (int key1 in _effList[key].Keys)
                 {
-                    SceneController.DestroyObjectFromView(_gameobjects[key][key1], _wrappers[key][key1]);
+                    EffectUIPool.Recycle(_effList[key][key1]);
+                    _effList[key][key1] = null;
                 }
             }
+            _effList.Clear();
             EffectUIPool.Recycle(_effectUI1);
             _effectUI1 = null;
             EffectUIPool.Recycle(_effectUI2);
@@ -110,18 +111,15 @@ namespace GFGGame
 
             string resPath = itemCfg.rarity == ConstDressRarity.Rarity_TIANYI ? "CK_all_01" : "CK_all_02";
 
-            if (countType == 10 && itemCfg.rarity > 2 && (!_gameobjects.ContainsKey(itemCfg.rarity) || !_gameobjects[itemCfg.rarity].ContainsKey(index)))
+            if (countType == 10 && itemCfg.rarity > 2 && (!_effList.ContainsKey(itemCfg.rarity) || !_effList[itemCfg.rarity].ContainsKey(index)))
             {
-                if (!_gameobjects.ContainsKey(itemCfg.rarity))
+                if (!_effList.ContainsKey(itemCfg.rarity))
                 {
-                    _gameobjects[itemCfg.rarity] = new Dictionary<int, GameObject>();
-                    _wrappers[itemCfg.rarity] = new Dictionary<int, GoWrapper>();
+                    _effList[itemCfg.rarity] = new Dictionary<int, EffectUI>();
                 }
                 GGraph holder = itemCfg.rarity == 3 ? item.m_comIcon.m_holder : item.m_comIcon.m_holder1;
-                SceneController.AddObjectToView(null, null, holder, resPath, out GameObject gameObject, out GoWrapper wrapper);
-                _gameobjects[itemCfg.rarity][index] = gameObject;
-                _wrappers[itemCfg.rarity][index] = wrapper;
-
+                EffectUI _effectUI = EffectUIPool.CreateEffectUI(holder, "ui_LuckyBox", resPath);
+                _effList[itemCfg.rarity][index] = _effectUI;
             }
             if (countType == 1 && itemCfg.rarity > 2 && _effectUI4 == null)
             {

+ 6 - 8
GameClient/Assets/Game/HotUpdate/Views/LuckyBox/LuckyBoxStarView.cs

@@ -22,8 +22,7 @@ namespace GFGGame
         // 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<GameObject> lineObj = new List<GameObject>();
-        private List<GoWrapper> lineWrapper = new List<GoWrapper>();
+        private List<EffectUI> effObj = new List<EffectUI>();
         private EffectUI _effectUI1;
         private EffectUI _effectUI2;
         private EffectUI _effectUI3;
@@ -77,9 +76,10 @@ namespace GFGGame
                     value[i] = null;
                 }
             }
-            for (int i = 0; i < lineObj.Count; i++)
+            for (int i = 0; i < effObj.Count; i++)
             {
-                SceneController.DestroyObjectFromView(lineObj[i], lineWrapper[i]);
+                EffectUIPool.Recycle(effObj[i]);
+                effObj[i] = null;
             }
 
             notClickComStars.Clear();
@@ -224,11 +224,9 @@ namespace GFGGame
                     comStar.target.GetChildAt(2).asCom.visible = true;
                     // comStar.target.GetChildAt(1).asCom.visible = false;
                     string resPath = _isLuckyBox ? "LINE_Bule" : "LINE";
-                    SceneController.AddObjectToView(null, null, comStar.m_comLine.m_holder, resPath, out GameObject gameObject, out GoWrapper wrapper);
-                    _effectUI1 = EffectUIPool.CreateEffectUI(comStar.m_comLine.m_holder, "ui_fight_new", resPath);
+                    EffectUI _effectUI = EffectUIPool.CreateEffectUI(comStar.m_comLine.m_holder, "ui_LuckyBox", resPath);
 
-                    lineObj.Add(gameObject);
-                    lineWrapper.Add(wrapper);
+                    effObj.Add(_effectUI);
                     UI_ComStar.ProxyEnd();
 
                     curComStar = comStars[i];