SliderValueText.cs 478 B

1234567891011121314151617181920212223
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using TMPro;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. [RequireComponent(typeof(TMP_Text))]
  7. public class SliderValueText : MonoBehaviour
  8. {
  9. private TMP_Text txt;
  10. public Slider slider;
  11. void Awake(){
  12. txt = GetComponent<TMP_Text>();
  13. }
  14. // Update is called once per frame
  15. void Update()
  16. {
  17. txt.text = $"{slider.value- slider.minValue}/{slider.maxValue-slider.minValue}";
  18. }
  19. }