using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; namespace KairoEngine.UI { public class SliderText : MonoBehaviour { public TextMeshProUGUI text; public string suffix = "%"; public float multiplier = 100; public Slider slider; public void OnEnable() { slider.onValueChanged.AddListener(delegate {UpdateText(); }); } void OnDisable() { slider.onValueChanged.RemoveListener(delegate {UpdateText(); }); } void Start() { UpdateText(); } public void UpdateText() { float value = slider.value * multiplier; value = value < 0.6 ? 0 : Mathf.CeilToInt(value); text.text = $"{(int)value}{suffix}"; } } }