mirror of
https://github.com/ConjureETS/Unity_Utils.git
synced 2026-03-23 20:40:58 +00:00
25 lines
663 B
C#
25 lines
663 B
C#
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.UI;
|
|
|
|
namespace UI
|
|
{
|
|
public class SliderUIComponent : UIComponentBase
|
|
{
|
|
[SerializeField] private Slider _slider;
|
|
|
|
public void SetValue(float value, float max)
|
|
{
|
|
_slider.maxValue = max;
|
|
_slider.value = value;
|
|
}
|
|
|
|
public void SetValue(float value) => _slider.value = value;
|
|
|
|
public float GetValue() => _slider.value;
|
|
|
|
public void OnValueChanged(UnityAction<float> callBack) => _slider.onValueChanged.AddListener(callBack);
|
|
|
|
private void OnDestroy() => _slider.onValueChanged?.RemoveAllListeners();
|
|
}
|
|
} |