NanoPark/Assets/Scripts/SliderIndicator.cs
2022-01-26 19:10:12 +05:30

24 lines
541 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SliderIndicator : MonoBehaviour
{
public Slider slider;
public Text text;
void Start()
{
slider.onValueChanged.AddListener(OnChanged);
text.text = slider.value.ToString();
}
void OnChanged(float value){
text.text = slider.value.ToString();
}
void OnValidate(){
if(GetComponent<Text>()!=null && text==null)
text = GetComponent<Text>();
}
}