hch
2025-09-11 aa72688fbfcba5cf8d90a7b34700bbe1f9ebee12
Main/System/SkillUI/SkillBaseCell.cs
@@ -52,6 +52,7 @@
    public void Init(int skillID, UnityAction onclick = null, bool showType = false)
    {
        LoadPrefab();   //存在被卸载的可能,重新加载
        var config = SkillConfig.Get(skillID);
        if (config == null)
        {
@@ -109,8 +110,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;
    }
}