| | |
| | | } |
| | | |
| | | //showState 0:不显示 1:新增 2:提升 |
| | | //giftID 0 :代表未激活灰色 -1:代表不能激活 棕色,其他根据配表 |
| | | //giftID 0 :代表灰色需升星激活 -1:代表棕色需觉醒激活,其他根据配表,没有天赋的外层控制显隐 |
| | | public void Init(int giftID, int lv, UnityAction onclick = null, int showState = 0) |
| | | { |
| | | giftBtn.AddListener(onclick); |
| | | if (HeroTalentConfig.HasKey(giftID)) |
| | | { |
| | | var config = HeroTalentConfig.Get(giftID); |
| | | qualityBG.SetSprite("GiftQualityBG" + config.Quality); |
| | | giftBtn.AddListener(onclick); |
| | | giftName.text = config.Name; |
| | | giftName.color = GetColor(config.Quality); |
| | | textOutline.OutlineColor = GetOutlineColor(config.Quality); |
| | |
| | | else |
| | | { |
| | | qualityBG.SetSprite("GiftQualityBG" + giftID); |
| | | giftBtn.RemoveAllListeners(); |
| | | giftName.text = string.Empty; |
| | | lvRect.SetActive(false); |
| | | stateImg.SetActive(false); |
| | |
| | | var scale = 1f; |
| | | var rect = cellContainer.GetComponent<RectTransform>(); |
| | | var parentRect = transform.GetComponent<RectTransform>(); |
| | | scale = parentRect.sizeDelta.x / rect.sizeDelta.x; |
| | | 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 = new Vector3(scale, scale, scale); |
| | | } |
| | | } |