Merged in fix/ragesliderfix (pull request #125)
fix: Range slider low value stuck in max positionpull/413/head
commit
1a6181842a
|
@ -533,31 +533,17 @@ namespace UnityEngine.UI.Extensions
|
||||||
//HANDLE DRAG EVENTS
|
//HANDLE DRAG EVENTS
|
||||||
m_LowOffset = m_HighOffset = Vector2.zero;
|
m_LowOffset = m_HighOffset = Vector2.zero;
|
||||||
Vector2 localMousePos;
|
Vector2 localMousePos;
|
||||||
if (m_HighHandleRect != null && RectTransformUtility.RectangleContainsScreenPoint(m_HighHandleRect, eventData.position, eventData.enterEventCamera))
|
if(m_LowHandleRect != null && LowValue == MaxValue && RectTransformUtility.RectangleContainsScreenPoint(m_LowHandleRect, eventData.position, eventData.enterEventCamera))
|
||||||
{
|
{
|
||||||
//dragging the high value handle
|
SetToMoveLowValueHandle(m_LowHandleRect, eventData);
|
||||||
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_HighHandleRect, eventData.position, eventData.pressEventCamera, out localMousePos))
|
}
|
||||||
{
|
else if (m_HighHandleRect != null && RectTransformUtility.RectangleContainsScreenPoint(m_HighHandleRect, eventData.position, eventData.enterEventCamera))
|
||||||
m_HighOffset = localMousePos;
|
{
|
||||||
}
|
SetToMoveHighValueHandle(m_HighHandleRect, eventData);
|
||||||
interactionState = InteractionState.High;
|
|
||||||
if (transition == Transition.ColorTint)
|
|
||||||
{
|
|
||||||
targetGraphic = m_HighHandleRect.GetComponent<Graphic>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (m_LowHandleRect != null && RectTransformUtility.RectangleContainsScreenPoint(m_LowHandleRect, eventData.position, eventData.enterEventCamera))
|
else if (m_LowHandleRect != null && RectTransformUtility.RectangleContainsScreenPoint(m_LowHandleRect, eventData.position, eventData.enterEventCamera))
|
||||||
{
|
{
|
||||||
//dragging the low value handle
|
SetToMoveLowValueHandle(m_LowHandleRect, eventData);
|
||||||
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_LowHandleRect, eventData.position, eventData.pressEventCamera, out localMousePos))
|
|
||||||
{
|
|
||||||
m_LowOffset = localMousePos;
|
|
||||||
}
|
|
||||||
interactionState = InteractionState.Low;
|
|
||||||
if (transition == Transition.ColorTint)
|
|
||||||
{
|
|
||||||
targetGraphic = m_LowHandleRect.GetComponent<Graphic>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -575,6 +561,34 @@ namespace UnityEngine.UI.Extensions
|
||||||
base.OnPointerDown(eventData);
|
base.OnPointerDown(eventData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetToMoveLowValueHandle(RectTransform transform, PointerEventData eventData)
|
||||||
|
{
|
||||||
|
//dragging the low value handle
|
||||||
|
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(transform, eventData.position, eventData.pressEventCamera, out var localMousePos))
|
||||||
|
{
|
||||||
|
m_LowOffset = localMousePos;
|
||||||
|
}
|
||||||
|
interactionState = InteractionState.Low;
|
||||||
|
if (transition == Transition.ColorTint)
|
||||||
|
{
|
||||||
|
targetGraphic = m_LowHandleRect.GetComponent<Graphic>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetToMoveHighValueHandle(RectTransform transform, PointerEventData eventData)
|
||||||
|
{
|
||||||
|
//dragging the low value handle
|
||||||
|
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(transform, eventData.position, eventData.pressEventCamera, out var localMousePos))
|
||||||
|
{
|
||||||
|
m_HighOffset = localMousePos;
|
||||||
|
}
|
||||||
|
interactionState = InteractionState.High;
|
||||||
|
if (transition == Transition.ColorTint)
|
||||||
|
{
|
||||||
|
targetGraphic = m_HighHandleRect.GetComponent<Graphic>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void OnDrag(PointerEventData eventData)
|
public virtual void OnDrag(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
if (!MayDrag(eventData))
|
if (!MayDrag(eventData))
|
||||||
|
|
Loading…
Reference in New Issue