From a47d69479643ec6ede95f07d895806b3d99774a5 Mon Sep 17 00:00:00 2001 From: SimonDarksideJ Date: Sun, 26 Nov 2023 15:00:36 +0000 Subject: [PATCH] Added argument to the UpdateLayout method for the HSS/VSS to move to a new starting page Resolves: https://github.com/Unity-UI-Extensions/com.unity.uiextensions/issues/451 --- Runtime/Scripts/Layout/HorizontalScrollSnap.cs | 11 ++++++++++- Runtime/Scripts/Layout/VerticalScrollSnap.cs | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Runtime/Scripts/Layout/HorizontalScrollSnap.cs b/Runtime/Scripts/Layout/HorizontalScrollSnap.cs index 846d2a3..59877a0 100644 --- a/Runtime/Scripts/Layout/HorizontalScrollSnap.cs +++ b/Runtime/Scripts/Layout/HorizontalScrollSnap.cs @@ -223,12 +223,21 @@ namespace UnityEngine.UI.Extensions /// /// used for changing / updating between screen resolutions /// - public void UpdateLayout() + public void UpdateLayout(bool resetPositionToStart = false) { _lerp = false; DistributePages(); + + if (resetPositionToStart) + { + _currentPage = StartingScreen; + } + if (MaskArea) + { UpdateVisible(); + } + SetScrollContainerPosition(); OnCurrentScreenChange(_currentPage); } diff --git a/Runtime/Scripts/Layout/VerticalScrollSnap.cs b/Runtime/Scripts/Layout/VerticalScrollSnap.cs index 8690856..4642241 100644 --- a/Runtime/Scripts/Layout/VerticalScrollSnap.cs +++ b/Runtime/Scripts/Layout/VerticalScrollSnap.cs @@ -218,11 +218,21 @@ namespace UnityEngine.UI.Extensions /// /// used for changing / updating between screen resolutions /// - public void UpdateLayout() + public void UpdateLayout(bool resetPositionToStart = false) { _lerp = false; DistributePages(); - if (MaskArea) UpdateVisible(); + + if (resetPositionToStart) + { + _currentPage = StartingScreen; + } + + if (MaskArea) + { + UpdateVisible(); + } + SetScrollContainerPosition(); OnCurrentScreenChange(_currentPage); }