private void UpdateAttrUI(Stats.EventArgs args) { Stats stats = this.GetStatsTarget(); if (!stats) { return; } string attrID = this.attribute.attribute.uniqueName; if (this.icon) { this.icon.overrideSprite = stats.GetAttrIcon(attrID); } if (this.color) { this.color.color = stats.GetAttrColor(attrID); } if (this.title) { this.title.text = stats.GetAttrDescription(attrID); } if (this.description) { this.description.text = stats.GetAttrDescription(attrID); } if (this.shortName) { this.shortName.text = stats.GetAttrShortName(attrID); } float curAttr = stats.GetAttrValue(attrID); float maxAttr = stats.GetAttrMaxValue(attrID); float minAttr = this.attribute.attribute.minValue; if (this.value) { this.value.text = string.Format( this.valueFormat, curAttr, maxAttr, minAttr ); } float percent = Mathf.InverseLerp(minAttr, maxAttr, curAttr); this.transitionTargetPercent = percent; this.transitionVelocity = 0f; this.transitionTime = Time.time; if ((this.transitionCurrentPercent < percent && !this.smoothTransitionUp) || (this.transitionCurrentPercent > percent && !this.smoothTransitionDown)) { this.transitionCurrentPercent = percent; } }
private void UpdateAttrUI(Stats.EventArgs args) { Stats stats = this.GetStatsTarget(); if (stats == null) { return; } string attrID = this.attribute.attribute.uniqueName; if (this.icon != null) { this.icon.overrideSprite = stats.GetAttrIcon(attrID); } if (this.color != null) { this.color.color = stats.GetAttrColor(attrID); } if (this.title != null) { this.title.text = stats.GetAttrDescription(attrID); } if (this.description != null) { this.description.text = stats.GetAttrDescription(attrID); } if (this.shortName != null) { this.shortName.text = stats.GetAttrShortName(attrID); } float curAttr = stats.GetAttrValue(attrID); float maxAttr = stats.GetAttrMaxValue(attrID); if (this.value != null) { this.value.text = string.Format( this.valueFormat, curAttr, maxAttr ); } if (this.valueFillImage != null) { this.valueFillImage.fillAmount = (curAttr / maxAttr); } if (this.valueScaleX != null) { this.valueScaleX.localScale = new Vector3( (curAttr / maxAttr), this.valueScaleX.localScale.y, this.valueScaleX.localScale.z ); } if (this.valueScaleY != null) { this.valueScaleY.localScale = new Vector3( this.valueScaleY.localScale.x, (curAttr / maxAttr), this.valueScaleY.localScale.z ); } }