心率,阻力逻辑调整

This commit is contained in:
lishuo committed 2022-06-14 18:37:58 +08:00
1 parent f25d0b7b8c
commit 0202814f67
5 files changed
+68 -29

No files matched your search

+22 -6
View File
@@ -37,23 +37,39 @@ public class PFUISlider : MonoBehaviour
public bool runCallback = false;
public void SetValueChanged(System.Action<float> a)
{
this.ValueChangedHandler = a;
slider = transform.GetComponent<Slider>();
slider.onValueChanged.RemoveAllListeners();
UIManager.AddEvent(slider.gameObject, EventTriggerType.EndDrag, (e) =>
{
OnValueChanged();
});
slider.onValueChanged.AddListener((f) =>
{
var step = 1f / (colorGradientList.Count-1);
var index = (int)Math.Round(f / step, 0);
slider.targetGraphic.color = colorGradientList[index];
text.text = $"{valueHandler(f).ToString("#0")}";
a.Invoke(f);
current = f;
});
}
float current;
System.Action<float> ValueChangedHandler;
private void OnValueChanged()
{
float f = current;
var step = 1f / (colorGradientList.Count - 1);
var index = (int)Math.Round(f / step, 0);
slider.targetGraphic.color = colorGradientList[index];
text.text = $"{valueHandler(f):#0}";
this.ValueChangedHandler?.Invoke(f);
}
public void SetValue(float a)
{
a = a > 1 ? 1 : a;
a = a < 0 ? 0 : a;
slider.value = a;
slider.onValueChanged?.Invoke(a);
OnValueChanged();
}
public float GetValue()