📅  最后修改于: 2022-03-11 14:49:22.442000             🧑  作者: Mango
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class SliderScript : MonoBehaviour
{
[SerializeField] private Slider slider; //attach slider here
[SerializeField] private TextMeshProUGUI sliderNumber; //attach TextMeshProText here
private void Start()
{
slider.onValueChanged.AddListener((value) =>
{
sliderNumber.text = value.ToString("0");
});
}
}