Merged in fix/scrollconflictmanagerconflict (pull request #94)

Fixed a conflict when using the ScrollConflictManager in child content of a HSS or VSS
pull/413/head
Simon Jackson 2020-09-28 13:02:38 +00:00
commit 8da09dc193
2 changed files with 24 additions and 0 deletions

View File

@ -12,6 +12,8 @@ namespace UnityEngine.UI.Extensions
[AddComponentMenu("Layout/Extensions/Horizontal Scroll Snap")] [AddComponentMenu("Layout/Extensions/Horizontal Scroll Snap")]
public class HorizontalScrollSnap : ScrollSnapBase public class HorizontalScrollSnap : ScrollSnapBase
{ {
private bool updated = true;
void Start() void Start()
{ {
_isVertical = false; _isVertical = false;
@ -23,6 +25,8 @@ namespace UnityEngine.UI.Extensions
void Update() void Update()
{ {
updated = false;
if (!_lerp && _scroll_rect.velocity == Vector2.zero) if (!_lerp && _scroll_rect.velocity == Vector2.zero)
{ {
if (!_settled && !_pointerDown) if (!_settled && !_pointerDown)
@ -243,6 +247,14 @@ namespace UnityEngine.UI.Extensions
/// <param name="eventData"></param> /// <param name="eventData"></param>
public override void OnEndDrag(PointerEventData eventData) public override void OnEndDrag(PointerEventData eventData)
{ {
if (updated)
{
return;
}
// to prevent double dragging, only act on EndDrag once per frame
updated = true;
_pointerDown = false; _pointerDown = false;
if (_scroll_rect.horizontal) if (_scroll_rect.horizontal)

View File

@ -12,6 +12,8 @@ namespace UnityEngine.UI.Extensions
[AddComponentMenu("Layout/Extensions/Vertical Scroll Snap")] [AddComponentMenu("Layout/Extensions/Vertical Scroll Snap")]
public class VerticalScrollSnap : ScrollSnapBase public class VerticalScrollSnap : ScrollSnapBase
{ {
private bool updated = true;
void Start() void Start()
{ {
_isVertical = true; _isVertical = true;
@ -23,6 +25,8 @@ namespace UnityEngine.UI.Extensions
void Update() void Update()
{ {
updated = false;
if (!_lerp && _scroll_rect.velocity == Vector2.zero) if (!_lerp && _scroll_rect.velocity == Vector2.zero)
{ {
if (!_settled && !_pointerDown) if (!_settled && !_pointerDown)
@ -236,6 +240,14 @@ namespace UnityEngine.UI.Extensions
/// <param name="eventData"></param> /// <param name="eventData"></param>
public override void OnEndDrag(PointerEventData eventData) public override void OnEndDrag(PointerEventData eventData)
{ {
if (updated)
{
return;
}
// to prevent double dragging, only act on EndDrag once per frame
updated = true;
_pointerDown = false; _pointerDown = false;
if (_scroll_rect.vertical) if (_scroll_rect.vertical)