📜  滑块脚本 unity - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:22.442000             🧑  作者: Mango

代码示例1
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");
        });
    }
}