hch
2 小时以前 9d6b41ab1727ea544629dfc81e5395b2eb6964b5
Main/System/SkillUI/SkillWordCell.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)
        {
@@ -102,8 +103,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;
    }
}