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/HeroHeadBaseNoTrainCell.cs | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/Main/System/HeroUI/HeroHeadBaseNoTrainCell.cs b/Main/System/HeroUI/HeroHeadBaseNoTrainCell.cs
index 446b672..c7de2f4 100644
--- a/Main/System/HeroUI/HeroHeadBaseNoTrainCell.cs
+++ b/Main/System/HeroUI/HeroHeadBaseNoTrainCell.cs
@@ -96,7 +96,9 @@
public async UniTask Init(int heroID, bool _gray = false, UnityAction onclick = null)
{
await LoadPrefab();
- clickBtn.AddListener(onclick);
+ if (this == null) return;
+ if (onclick != null)
+ clickBtn.AddListener(onclick);
var heroConfig = HeroConfig.Get(heroID);
qualityBG.SetSprite("heroheadBG" + heroConfig.Quality);
@@ -129,19 +131,23 @@
}
if (cellContainer == null)
{
- cellContainer = await UIUtility.CreateWidget("HeroHeadBaseNoTrainCell", "Container_HeadCell");
+ var inst = await UIUtility.CreateWidget("HeroHeadBaseNoTrainCell", "Container_HeadCell");
if (this == null)
{
- if (cellContainer != null)
- {
- DestroyImmediate(cellContainer);
- }
+ 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