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/HeroHeadBaseCell.cs | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/Main/System/HeroUI/HeroHeadBaseCell.cs b/Main/System/HeroUI/HeroHeadBaseCell.cs
index 4422cf0..5dcc15a 100644
--- a/Main/System/HeroUI/HeroHeadBaseCell.cs
+++ b/Main/System/HeroUI/HeroHeadBaseCell.cs
@@ -134,13 +134,14 @@
void Awake()
{
- LoadPrefab();
+ LoadPrefab().Forget();
}
// 姝﹀皢灏忓ご鍍忥紝锛堣亴涓氬拰鍚嶇О涓嶅啀姝ょ鐞嗭紝鍚勪釜鐣岄潰鎺掔増涓嶅悓锛�
- public void Init(int heroID, int skinID, int star = 0, int awakelv = 0, int lv = 0, UnityAction onclick = null)
+ public async UniTask Init(int heroID, int skinID, int star = 0, int awakelv = 0, int lv = 0, UnityAction onclick = null)
{
- LoadPrefab(); //瀛樺湪琚嵏杞界殑鍙兘锛岄噸鏂板姞杞�
+ await LoadPrefab(); //瀛樺湪琚嵏杞界殑鍙兘锛岄噸鏂板姞杞�
+ if (this == null) return;
if (onclick != null)
{
clickBtn.AddListener(onclick);
@@ -192,7 +193,8 @@
// 姝﹀皢灏忓ご鍍� Async鐗堟湰
public async UniTask InitAsync(int heroID, int skinID, int star = 0, int awakelv = 0, int lv = 0, UnityAction onclick = null)
{
- LoadPrefab(); //瀛樺湪琚嵏杞界殑鍙兘锛岄噸鏂板姞杞�
+ await LoadPrefab(); //瀛樺湪琚嵏杞界殑鍙兘锛岄噸鏂板姞杞�
+ if (this == null) return;
if (onclick != null)
{
clickBtn.AddListener(onclick);
@@ -265,19 +267,23 @@
}
if (cellContainer == null)
{
- cellContainer = await UIUtility.CreateWidget("HeroHeadBaseCell", "Container_HeadCell");
+ var inst = await UIUtility.CreateWidget("HeroHeadBaseCell", "Container_HeadCell");
if (this == null)
{
- if (cellContainer != null)
- {
- DestroyImmediate(cellContainer);
- return;
- }
+ if (inst != null) DestroyImmediate(inst);
+ return;
}
if (cellContainer != null)
{
+ 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