using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using XCharts.Runtime; public class PercentTool : MonoBehaviour { public BaseChart chart; public int index; public float value; void Update() { value = (float)(chart.series[0].data[index].data[1] / chart.series[1].data[index].data[1]); if (value > 0) { GetComponent().text = string.Format("{0:f2}%", value * 100); } else { GetComponent().text = ""; } transform.GetComponent().localPosition = new Vector3(Mathf.Lerp(-150, 175, Mathf.Clamp(value, 0.5f, 1)), transform.GetComponent().localPosition.y, transform.GetComponent().localPosition.z); } }