From d393830a1d855ef4f8150ae5089f0e4dc5c8bacc Mon Sep 17 00:00:00 2001 From: "Simon (darkside) Jackson" Date: Tue, 30 Jun 2020 12:55:45 +0100 Subject: [PATCH] fix: HSS/VSS ScrollSnap button fixes when infinite control applied Resolves #132 --- Scripts/Layout/ScrollSnapBase.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Scripts/Layout/ScrollSnapBase.cs b/Scripts/Layout/ScrollSnapBase.cs index ac1f302..aa9bb93 100644 --- a/Scripts/Layout/ScrollSnapBase.cs +++ b/Scripts/Layout/ScrollSnapBase.cs @@ -317,7 +317,14 @@ namespace UnityEngine.UI.Extensions if (!_lerp) StartScreenChange(); _lerp = true; - CurrentPage = _currentPage + 1; + if (_isInfinite) + { + CurrentPage = GetPageforPosition(_screensContainer.anchoredPosition) + 1; + } + else + { + CurrentPage = _currentPage + 1; + } GetPositionforPage(_currentPage, ref _lerp_target); ScreenChange(); } @@ -332,7 +339,14 @@ namespace UnityEngine.UI.Extensions if (!_lerp) StartScreenChange(); _lerp = true; - CurrentPage = _currentPage - 1; + if (_isInfinite) + { + CurrentPage = GetPageforPosition(_screensContainer.anchoredPosition) - 1; + } + else + { + CurrentPage = _currentPage - 1; + } GetPositionforPage(_currentPage, ref _lerp_target); ScreenChange(); } @@ -508,7 +522,7 @@ namespace UnityEngine.UI.Extensions var infiniteScroll = GetComponent(); if (ChildObjects != null && ChildObjects.Length > 0 && infiniteScroll != null && !infiniteScroll.InitByUser) { - Debug.LogError("When using procedural children with a ScrollSnap (Adding Prefab ChildObjects) and the Infinite Scroll component\nYou must set the 'InitByUser' option to true, to enable late initialising"); + Debug.LogError($"[{gameObject.name}]When using procedural children with a ScrollSnap (Adding Prefab ChildObjects) and the Infinite Scroll component\nYou must set the 'InitByUser' option to true, to enable late initialising"); } }