From 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 11 五月 2026 16:20:37 +0800
Subject: [PATCH] Merge branch 'master' into h5version
---
Main/System/SkillUI/SkillWordCell.cs | 39 +++++++++++++++++++++++++++++++++------
1 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/Main/System/SkillUI/SkillWordCell.cs b/Main/System/SkillUI/SkillWordCell.cs
index 168f1f9..6ffe0f3 100644
--- a/Main/System/SkillUI/SkillWordCell.cs
+++ b/Main/System/SkillUI/SkillWordCell.cs
@@ -1,6 +1,7 @@
锘縰sing UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
+using Cysharp.Threading.Tasks;
public class SkillWordCell : MonoBehaviour
{
@@ -47,11 +48,13 @@
void Awake()
{
- LoadPrefab();
+ LoadPrefab().Forget();
}
- public void Init(int skillID, UnityAction onclick = null, bool showType = false)
+ public async UniTask Init(int skillID, UnityAction onclick = null, bool showType = false)
{
+ await LoadPrefab(); //瀛樺湪琚嵏杞界殑鍙兘锛岄噸鏂板姞杞�
+ if (this == null) return;
var config = SkillConfig.Get(skillID);
if (config == null)
{
@@ -76,7 +79,7 @@
}
GameObject cellContainer;
- protected void LoadPrefab()
+ protected async UniTask LoadPrefab()
{
if (cellContainer != null)
return;
@@ -89,7 +92,20 @@
}
if (cellContainer == null)
{
- cellContainer = UIUtility.CreateWidget("SkillWordCell", "Container_SkillCell");
+ var inst = await UIUtility.CreateWidget("SkillWordCell", "Container_SkillCell");
+
+ if (this == null)
+ {
+ if (null != inst) DestroyImmediate(inst);
+ return;
+ }
+
+ if (cellContainer != null)
+ {
+ DestroyImmediate(inst);
+ return;
+ }
+ cellContainer = inst;
if (cellContainer != null)
{
@@ -102,8 +118,19 @@
var scale = 1f;
var rect = cellContainer.GetComponent<RectTransform>();
var parentRect = transform.GetComponent<RectTransform>();
- scale = parentRect.sizeDelta.x / rect.sizeDelta.x;
- cellContainer.transform.localScale = new Vector3(scale, scale, scale);
+ float width = parentRect.sizeDelta.x;
+ if (width <= 0f)
+ {
+ //澶栭儴鎺у埗浜嗗昂瀵歌幏鍙栦负0
+ GridLayoutGroup grid = GetComponentInParent<GridLayoutGroup>();
+ if (grid != null)
+ {
+ width = grid.cellSize.x;
+ }
+
+ }
+ scale = width / rect.sizeDelta.x;
+ cellContainer.transform.localScale = cellContainer.transform.localScale * scale;
}
}
--
Gitblit v1.8.0