38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
using TMPro;
|
|
|
|
public class MoveSliderDragHandler : AbstractSlider, IDragHandler, IBeginDragHandler, IEndDragHandler
|
|
{
|
|
public TMP_Text warningText;
|
|
public float warningThreshholdValue = 0.65f;
|
|
|
|
public ContinuoslocomotionConfigurator configurator;
|
|
|
|
override public void OnEndDrag(PointerEventData eventData)
|
|
{
|
|
base.OnEndDrag(eventData);
|
|
configurator.UpdateSpeed(CurrentValue);
|
|
}
|
|
|
|
override protected void UpdateSlider(PointerEventData eventData, bool draggingEnded = false)
|
|
{
|
|
base.UpdateSlider(eventData, draggingEnded);
|
|
DisplayWarningTextIfNecessary();
|
|
}
|
|
|
|
override protected void UpdateHandlePosition()
|
|
{
|
|
base.UpdateHandlePosition();
|
|
DisplayWarningTextIfNecessary();
|
|
}
|
|
|
|
protected void DisplayWarningTextIfNecessary()
|
|
{
|
|
if (CurrentValue > (warningThreshholdValue * (maxValue - minValue) + minValue)) warningText.gameObject.SetActive(true);
|
|
else warningText.gameObject.SetActive(false);
|
|
}
|
|
|
|
}
|