using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UISlider : MonoBehaviour { [SerializeField] private TMPro.TextMeshProUGUI _text; [SerializeField] private string _prefix; private Slider _slider; private void Awake() { _slider = GetComponent(); } private void OnEnable() { _slider.onValueChanged.AddListener(OnValueChange); } private void OnDisable() { _slider.onValueChanged.RemoveListener(OnValueChange); } private void OnValueChange(float value) { _text.SetText(_prefix + value); } }