31 lines
615 B
C#
31 lines
615 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
[RequireComponent(typeof(TMP_Text))]
|
|
public class SliderValueText : MonoBehaviour
|
|
{
|
|
public Slider slider;
|
|
|
|
|
|
void OnValidate(){
|
|
if(slider==null){
|
|
slider = GetComponentInParent<Slider>();
|
|
}
|
|
}
|
|
void Start()
|
|
{
|
|
slider.onValueChanged.AddListener(RefreshText);
|
|
txt= GetComponent<TMP_Text>();
|
|
RefreshText(slider.value);
|
|
|
|
}
|
|
TMP_Text txt;
|
|
|
|
void RefreshText(float value){
|
|
txt.text = slider.value.ToString("n3");
|
|
}
|
|
}
|