33 lines
657 B
C#
33 lines
657 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class UISlider : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] private TMPro.TextMeshProUGUI _text;
|
||
|
[SerializeField] private string _prefix;
|
||
|
|
||
|
private Slider _slider;
|
||
|
|
||
|
private void Awake()
|
||
|
{
|
||
|
_slider = GetComponent<Slider>();
|
||
|
}
|
||
|
|
||
|
private void OnEnable()
|
||
|
{
|
||
|
_slider.onValueChanged.AddListener(OnValueChange);
|
||
|
}
|
||
|
|
||
|
private void OnDisable()
|
||
|
{
|
||
|
_slider.onValueChanged.RemoveListener(OnValueChange);
|
||
|
}
|
||
|
|
||
|
private void OnValueChange(float value)
|
||
|
{
|
||
|
_text.SetText(_prefix + value);
|
||
|
}
|
||
|
}
|