Skip to content
Permalink
Browse files

Fixed an issue with touches and UI Slider.

  • Loading branch information...
valyard committed Aug 1, 2017
1 parent 351487a commit 78e78c1c244fb68aad67df4d41735e76fe221778
@@ -48,7 +48,7 @@ public IPointerLogger PointerLogger
{
if (value == null) return;
if (pointerLogger == value) return;
pointerLogger.Dispose();
if (pointerLogger != null) pointerLogger.Dispose();
pointerLogger = value;
}
}
@@ -198,6 +198,7 @@ internal int INTERNAL_Release()
private void enable()
{
ui = new UIStandardInputModule(this);
TouchManager.Instance.PointersAdded += ui.ProcessAdded;
TouchManager.Instance.PointersUpdated += ui.ProcessUpdated;
TouchManager.Instance.PointersPressed += ui.ProcessPressed;
TouchManager.Instance.PointersReleased += ui.ProcessReleased;
@@ -209,6 +210,7 @@ private void disable()
{
if (TouchManager.Instance != null && ui != null)
{
TouchManager.Instance.PointersAdded -= ui.ProcessAdded;
TouchManager.Instance.PointersUpdated -= ui.ProcessUpdated;
TouchManager.Instance.PointersPressed -= ui.ProcessPressed;
TouchManager.Instance.PointersReleased -= ui.ProcessReleased;
@@ -433,6 +435,43 @@ private void convertRaycast(RaycastHitUI old, ref RaycastResult current)

#region Event processors

public virtual void ProcessAdded(object sender, PointerEventArgs pointerEventArgs)
{
#if UNITY_5_6_OR_NEWER
uiSampler.Begin();
#endif

var pointers = pointerEventArgs.Pointers;
var raycast = new RaycastResult();
var count = pointers.Count;
for (var i = 0; i < count; i++)
{
var pointer = pointers[i];
var over = pointer.GetOverData();

// Don't update the pointer if it is not over an UI element
if (over.Type != HitData.HitType.UI) continue;

PointerEventData data;
GetPointerData(pointer.Id, out data, true);
data.Reset();
var target = over.Target;
var currentOverGo = target == null ? null : target.gameObject;

data.position = pointer.Position;
data.delta = Vector2.zero;
convertRaycast(over.RaycastHitUI, ref raycast);
raycast.screenPosition = data.position;
data.pointerCurrentRaycast = raycast;

input.HandlePointerExitAndEnter(data, currentOverGo);
}

#if UNITY_5_6_OR_NEWER
uiSampler.End();
#endif
}

public virtual void ProcessUpdated(object sender, PointerEventArgs pointerEventArgs)
{
#if UNITY_5_6_OR_NEWER
@@ -445,16 +484,19 @@ public virtual void ProcessUpdated(object sender, PointerEventArgs pointerEventA
for (var i = 0; i < count; i++)
{
var pointer = pointers[i];
var over = pointer.GetOverData();

// Don't update the pointer if it is pressed not over an UI element
if ((pointer.Buttons & Pointer.PointerButtonState.AnyButtonPressed) > 0)
{
var press = pointer.GetPressData();
if (press.Type != HitData.HitType.UI) continue;
}

var over = pointer.GetOverData();
// Don't update the pointer if it is not over an UI element
if (over.Type != HitData.HitType.UI) continue;
else
{
// Don't update the pointer if it is not over an UI element
if (over.Type != HitData.HitType.UI) continue;
}

PointerEventData data;
GetPointerData(pointer.Id, out data, true);
@@ -535,6 +577,7 @@ public virtual void ProcessPressed(object sender, PointerEventArgs pointerEventA
data.delta = Vector2.zero;
data.dragging = false;
data.useDragThreshold = true;
data.position = pointer.Position;
data.pressPosition = pointer.Position;
data.pointerPressRaycast = data.pointerCurrentRaycast;

0 comments on commit 78e78c1

Please sign in to comment.
You can’t perform that action at this time.