hch
5 小时以前 9d6b41ab1727ea544629dfc81e5395b2eb6964b5
Main/System/SkillUI/SkillBaseCell.cs
@@ -45,6 +45,20 @@
        }
    }
    Image m_WordBG;
    Image wordBG
    {
        get
        {
            if (m_WordBG == null)
            {
                m_WordBG = this.transform.GetComponent<Image>("Container_SkillCell/Image");
            }
            return m_WordBG;
        }
    }
    void Awake()
    {
        LoadPrefab();
@@ -52,6 +66,7 @@
    public void Init(int skillID, UnityAction onclick = null, bool showType = false)
    {
        LoadPrefab();   //存在被卸载的可能,重新加载
        var config = SkillConfig.Get(skillID);
        if (config == null)
        {
@@ -75,10 +90,12 @@
        if (showType)
        {
            skillType.text = Language.Get(config.FuncType == 1 ? "HeroSkillType_1" : "HeroSkillType_2");
            wordBG.SetActive(true);
        }
        else
        {
        {
            skillType.text = string.Empty;
            wordBG.SetActive(false);
        }
    }
@@ -109,8 +126,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;
    }
}