From 0e636bf937f8867945aac9a569f052586503cf3a Mon Sep 17 00:00:00 2001 From: "Simon (darkside) Jackson" Date: Mon, 28 Sep 2020 14:00:09 +0100 Subject: [PATCH] Fixed a conflict when using the ScrollConflictManager in child content of a HSS or VSS --- Runtime/Scripts/Layout/HorizontalScrollSnap.cs | 12 ++++++++++++ Runtime/Scripts/Layout/VerticalScrollSnap.cs | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Runtime/Scripts/Layout/HorizontalScrollSnap.cs b/Runtime/Scripts/Layout/HorizontalScrollSnap.cs index f533370..1baacfd 100644 --- a/Runtime/Scripts/Layout/HorizontalScrollSnap.cs +++ b/Runtime/Scripts/Layout/HorizontalScrollSnap.cs @@ -12,6 +12,8 @@ namespace UnityEngine.UI.Extensions [AddComponentMenu("Layout/Extensions/Horizontal Scroll Snap")] public class HorizontalScrollSnap : ScrollSnapBase { + private bool updated = true; + void Start() { _isVertical = false; @@ -23,6 +25,8 @@ namespace UnityEngine.UI.Extensions void Update() { + updated = false; + if (!_lerp && _scroll_rect.velocity == Vector2.zero) { if (!_settled && !_pointerDown) @@ -243,6 +247,14 @@ namespace UnityEngine.UI.Extensions /// public override void OnEndDrag(PointerEventData eventData) { + if (updated) + { + return; + } + + // to prevent double dragging, only act on EndDrag once per frame + updated = true; + _pointerDown = false; if (_scroll_rect.horizontal) diff --git a/Runtime/Scripts/Layout/VerticalScrollSnap.cs b/Runtime/Scripts/Layout/VerticalScrollSnap.cs index a8228d8..e0c5bb0 100644 --- a/Runtime/Scripts/Layout/VerticalScrollSnap.cs +++ b/Runtime/Scripts/Layout/VerticalScrollSnap.cs @@ -12,6 +12,8 @@ namespace UnityEngine.UI.Extensions [AddComponentMenu("Layout/Extensions/Vertical Scroll Snap")] public class VerticalScrollSnap : ScrollSnapBase { + private bool updated = true; + void Start() { _isVertical = true; @@ -23,6 +25,8 @@ namespace UnityEngine.UI.Extensions void Update() { + updated = false; + if (!_lerp && _scroll_rect.velocity == Vector2.zero) { if (!_settled && !_pointerDown) @@ -236,6 +240,14 @@ namespace UnityEngine.UI.Extensions /// public override void OnEndDrag(PointerEventData eventData) { + if (updated) + { + return; + } + + // to prevent double dragging, only act on EndDrag once per frame + updated = true; + _pointerDown = false; if (_scroll_rect.vertical)