何晓捷 2 år sedan
förälder
incheckning
0d4889f25e

+ 30 - 21
GameClient/Assets/Game/HotUpdate/Views/EnduringGiftBox/SpecialOfferGiftBoxView.cs

@@ -45,13 +45,16 @@ namespace GFGGame
 
         public override void Dispose()
         {
+            base.Dispose();
+            SceneController.DestroyObjectFromView(_gameObject1, _wrapper1);
+            SceneController.DestroyObjectFromView(_gameObject2, _wrapper2);
+            SceneController.DestroyObjectFromView(_gameObject3, _wrapper3);
+            DestroyObjectFromView();
             if (_ui != null)
             {
                 _ui.Dispose();
                 _ui = null;
             }
-
-            base.Dispose();
         }
 
         protected override void OnShown()
@@ -83,14 +86,25 @@ namespace GFGGame
         private void AddEffect()
         {
             string resPath1 = ResPathUtil.GetViewEffectPath("ui_Activity", "Prefer_person");
-            SceneController.AddObjectToView(null, null, _ui.m_holderBaby, resPath1,
-                out _gameObject1, out _wrapper1);
-            string resPath2 = ResPathUtil.GetViewEffectPath("ui_Activity", "Prefer_chixu_tx");
-            SceneController.AddObjectToView(null, null, _ui.m_holderChiXuTx, resPath2,
-                out _gameObject2, out _wrapper2);
-            string resPath3 = ResPathUtil.GetViewEffectPath("ui_Activity", "Prefer_one_tx");
-            SceneController.AddObjectToView(null, null, _ui.m_holderOneTx, resPath3,
-                out _gameObject3, out _wrapper3);
+            if (_gameObject1 == null)
+            {
+                SceneController.AddObjectToView(null, null, _ui.m_holderBaby, resPath1,
+                    out _gameObject1, out _wrapper1);
+            }
+
+            if (_gameObject2 == null)
+            {
+                string resPath2 = ResPathUtil.GetViewEffectPath("ui_Activity", "Prefer_chixu_tx");
+                SceneController.AddObjectToView(null, null, _ui.m_holderChiXuTx, resPath2,
+                    out _gameObject2, out _wrapper2);
+            }
+
+            if (_gameObject3 == null)
+            {
+                string resPath3 = ResPathUtil.GetViewEffectPath("ui_Activity", "Prefer_one_tx");
+                SceneController.AddObjectToView(null, null, _ui.m_holderOneTx, resPath3,
+                    out _gameObject3, out _wrapper3);
+            }
         }
 
         public void UpTime()
@@ -189,7 +203,7 @@ namespace GFGGame
             {
                 mTxtUrc = $"永久限购{remainBuyNum}/{shopCfg.maxBuyNum}";
             }
-            
+
             uiItem.m_btnBuy.m_txtOldPrice.text = shopCfg.originalPrice.ToString();
             if (shopCfg.costType == CostType.ITEM)
             {
@@ -219,7 +233,7 @@ namespace GFGGame
                 uiItem.m_btnBuy.m_txtNewPrice.x = 125;
                 uiItem.m_btnBuy.m_txtOldPrice.x = 30;
             }
-            
+
             if (remainBuyNum == 0)
             {
                 //已售完
@@ -312,7 +326,7 @@ namespace GFGGame
             uiItemChild.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfgChild);
             uiItemChild.m_num.text = itemArr[1].ToString();
             uiItemChild.target.data = itemCfgChild;
-            
+
             if (!_graphList.Contains(uiItemChild.m_holderItem))
             {
                 string resPath = ResPathUtil.GetViewEffectPath("ui_Activity", "Prefer_kuang");
@@ -322,7 +336,7 @@ namespace GFGGame
                 _gameObjectList.Add(gameObject);
                 _wrapperList.Add(wrapper);
             }
-            
+
             uiItemChild.m_t0.Play();
 
             UI_ComRewardIconItem.ProxyEnd();
@@ -385,7 +399,7 @@ namespace GFGGame
                 ViewManager.Show<ItemExchangeView>(cfg.id);
             }
         }
-        
+
         private void DestroyObjectFromView()
         {
             foreach (var itemGameObject in _gameObjectList)
@@ -395,7 +409,7 @@ namespace GFGGame
                     GameObject.DestroyImmediate(itemGameObject);
                 }
             }
-            
+
             _gameObjectList.Clear();
 
             foreach (var itemWrapper in _wrapperList)
@@ -412,12 +426,7 @@ namespace GFGGame
 
         protected override void OnHide()
         {
-            SceneController.DestroyObjectFromView(_gameObject1, _wrapper1);
-            SceneController.DestroyObjectFromView(_gameObject2, _wrapper2);
-            SceneController.DestroyObjectFromView(_gameObject3, _wrapper3);
-            DestroyObjectFromView();
             this.RemoveEventListener();
-            // Dispose();
             base.Hide();
         }