From 1ab047b5fdd933c38ba0519ec2e83a44512ea8d7 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期四, 26 三月 2026 17:46:11 +0800
Subject: [PATCH] webgl代码合并 1

---
 Main/System/HeroUI/GiftBaseCell.cs |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/Main/System/HeroUI/GiftBaseCell.cs b/Main/System/HeroUI/GiftBaseCell.cs
index 31b83cf..4113405 100644
--- a/Main/System/HeroUI/GiftBaseCell.cs
+++ b/Main/System/HeroUI/GiftBaseCell.cs
@@ -115,14 +115,15 @@
 
     void Awake()
     {
-        LoadPrefab();
+        LoadPrefab().Forget();
     }
 
     //showState 0锛氫笉鏄剧ず 1锛氭柊澧� 2锛氭彁鍗�
     //giftID 0 :浠h〃鐏拌壊闇�鍗囨槦婵�娲� -1锛氫唬琛ㄦ鑹查渶瑙夐啋婵�娲伙紝鍏朵粬鏍规嵁閰嶈〃锛屾病鏈夊ぉ璧嬬殑澶栧眰鎺у埗鏄鹃殣
-    public void Init(int giftID, int lv, int showState = 0, int heroID = 0, int index = 0, int awakeLevel = 0)
+    public async UniTask Init(int giftID, int lv, int showState = 0, int heroID = 0, int index = 0, int awakeLevel = 0)
     {
-        LoadPrefab();   //瀛樺湪琚嵏杞界殑鍙兘锛岄噸鏂板姞杞�
+        await LoadPrefab();   //瀛樺湪琚嵏杞界殑鍙兘锛岄噸鏂板姞杞�
+        if (this == null) return;
         if (HeroTalentConfig.HasKey(giftID))
         {
             var config = HeroTalentConfig.Get(giftID);
@@ -256,19 +257,23 @@
         }
         if (cellContainer == null)
         {
-            cellContainer = await UIUtility.CreateWidget("GiftBaseCell", "Container_GiftCell");
+            var inst = await UIUtility.CreateWidget("GiftBaseCell", "Container_GiftCell");
             
             if (this == null)
             {
-                if (null != cellContainer)
-                {
-                    GameObject.DestroyImmediate(cellContainer);
-                }
+                if (null != inst) GameObject.DestroyImmediate(inst);
                 return;
             }
 
             if (cellContainer != null)
             {
+                GameObject.DestroyImmediate(inst);
+                return;
+            }
+            cellContainer = inst;
+
+            if (cellContainer != null)
+            {
                 cellContainer.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one);
                 cellContainer.transform.SetAsFirstSibling();
             }

--
Gitblit v1.8.0