public void Assign(Stats.Info source, string text) { hasSource = true; current = source; float statSize = 0f; statSize += transform.GetComponentInChildren <RectTransform>().sizeDelta.x; var bgSize = background.sizeDelta; bgSize.x += (statSize + spacing); gameObject.SetActive(true); image.sprite = source.Icon; image.color = source.Color; textMesh.text = text; RectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, image.flexibleWidth + textMesh.preferredWidth + spacing); }
private bool HandleStat(int index, IAttributeHolder attributes, Id id, Stats.Info info) { if (attributes.Args.TryGetValue(id, out var baseValue, out var value)) { if (value == 0) { infos[index].TextMesh.color = normal; } else if (value > 0) { infos[index].TextMesh.color = bonus; } else { infos[index].TextMesh.color = malus; } infos[index].Assign(info, $"{baseValue + value}"); return(true); } return(false); }