Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit d393830

Browse files
fix: HSS/VSS ScrollSnap button fixes when infinite control applied
Resolves #132
1 parent f44afc7 commit d393830

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Scripts/Layout/ScrollSnapBase.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,14 @@ public void NextScreen()
317317
if (!_lerp) StartScreenChange();
318318

319319
_lerp = true;
320-
CurrentPage = _currentPage + 1;
320+
if (_isInfinite)
321+
{
322+
CurrentPage = GetPageforPosition(_screensContainer.anchoredPosition) + 1;
323+
}
324+
else
325+
{
326+
CurrentPage = _currentPage + 1;
327+
}
321328
GetPositionforPage(_currentPage, ref _lerp_target);
322329
ScreenChange();
323330
}
@@ -332,7 +339,14 @@ public void PreviousScreen()
332339
if (!_lerp) StartScreenChange();
333340

334341
_lerp = true;
335-
CurrentPage = _currentPage - 1;
342+
if (_isInfinite)
343+
{
344+
CurrentPage = GetPageforPosition(_screensContainer.anchoredPosition) - 1;
345+
}
346+
else
347+
{
348+
CurrentPage = _currentPage - 1;
349+
}
336350
GetPositionforPage(_currentPage, ref _lerp_target);
337351
ScreenChange();
338352
}
@@ -508,7 +522,7 @@ private void OnValidate()
508522
var infiniteScroll = GetComponent<UI_InfiniteScroll>();
509523
if (ChildObjects != null && ChildObjects.Length > 0 && infiniteScroll != null && !infiniteScroll.InitByUser)
510524
{
511-
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");
525+
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");
512526
}
513527
}
514528

0 commit comments

Comments
 (0)