yyl
2025-08-25 cec8b67d82c2c2c1662d55c818c4a46bcc0487db
Main/System/HeroUI/GiftBaseCell.cs
@@ -45,6 +45,19 @@
        }
    }
    OutlineEx m_TextOutline;
    OutlineEx textOutline
    {
        get
        {
            if (m_TextOutline == null)
            {
                m_TextOutline = this.transform.GetComponent<OutlineEx>("Container_GiftCell/name");
            }
            return m_TextOutline;
        }
    }
    Transform m_LvRect;
    Transform lvRect
    {
@@ -65,7 +78,7 @@
        {
            if (m_LvText == null)
            {
                m_LvText = this.transform.GetComponent<Text>("Container_GiftCell/lv");
                m_LvText = this.transform.GetComponent<Text>("Container_GiftCell/lvrect/lv");
            }
            return m_LvText;
        }
@@ -84,6 +97,8 @@
        }
    }
    void Awake()
    {
        LoadPrefab();
@@ -91,7 +106,7 @@
    //showState 0:不显示 1:新增 2:提升
    //giftID 0 :代表未激活灰色 -1:代表不能激活 棕色,其他根据配表
    private void Init(int giftID, int lv, UnityAction onclick = null, int showState = 0)
    public void Init(int giftID, int lv, UnityAction onclick = null, int showState = 0)
    {
        if (HeroTalentConfig.HasKey(giftID))
        {
@@ -99,10 +114,9 @@
            qualityBG.SetSprite("GiftQualityBG" + config.Quality);
            giftBtn.AddListener(onclick);
            giftName.text = config.Name;
            giftName.color = GetColor(config.Quality);
            textOutline.OutlineColor = GetOutlineColor(config.Quality);
            lvText.text = lv.ToString();
            lvText.color = GetColor(1);
            Outline textOutline = lvText.GetComponent<Outline>();
            textOutline.effectColor = GetOutlineColor(config.Quality);
            lvRect.SetActive(lv > 0);
            stateImg.SetActive(showState > 0);
            stateImg.SetSprite("GiftState" + showState);
@@ -148,24 +162,24 @@
        if (quality == 1)
        {
            //692088
            return new Color32(105, 32, 136, 255);
            return new Color32(105, 32, 136, 128);
        }
        else if (quality == 2)
        {
            //886220
            return new Color32(136, 98, 32, 255);
            return new Color32(136, 98, 32, 128);
        }
        else if (quality == 3)
        {
            //884a20
            return new Color32(136, 74, 32, 255);
            return new Color32(136, 74, 32, 128);
        }
        else if (quality == 4)
        {
            //882020
            return new Color32(136, 32, 32, 255);
            return new Color32(136, 32, 32, 128);
        }
        return new Color32(255, 255, 255, 255);
        return new Color32(0, 0, 0, 128);
    }
    GameObject cellContainer;
@@ -174,7 +188,7 @@
        if (cellContainer != null)
            return;
        
        var tmp = transform.Find("Container_SkillCell");
        var tmp = transform.Find("Container_GiftCell");
        if (tmp != null)
        {
            cellContainer = tmp.gameObject;
@@ -182,7 +196,7 @@
        }
        if (cellContainer == null)
        {
            cellContainer = UIUtility.CreateWidget("SkillBaseCell", "Container_SkillCell");
            cellContainer = UIUtility.CreateWidget("GiftBaseCell", "Container_GiftCell");
            if (cellContainer != null)
            {
@@ -190,6 +204,13 @@
                cellContainer.transform.SetAsFirstSibling();
            }
        }
        //缩放到和父rect一样大
        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);
    }
}