yyl
2026-05-11 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96
Main/System/SkillUI/SkillWordCell.cs
@@ -1,6 +1,7 @@
using 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)
            {
@@ -114,7 +130,7 @@
            
        }
        scale = width / rect.sizeDelta.x;
        cellContainer.transform.localScale = new Vector3(scale, scale, scale);
        cellContainer.transform.localScale = cellContainer.transform.localScale * scale;
    }
}