diff --git a/Scripts/Layout/HorizontalScrollSnap.cs b/Scripts/Layout/HorizontalScrollSnap.cs
index 6943d1a..ed43336 100644
--- a/Scripts/Layout/HorizontalScrollSnap.cs
+++ b/Scripts/Layout/HorizontalScrollSnap.cs
@@ -181,7 +181,7 @@ namespace UnityEngine.UI.Extensions
DistributePages();
if (MaskArea) UpdateVisible();
SetScrollContainerPosition();
- ChangeBulletsInfo(_currentPage);
+ OnCurrentScreenChange(_currentPage);
}
private void OnRectTransformDimensionsChange()
diff --git a/Scripts/Layout/ScrollSnapBase.cs b/Scripts/Layout/ScrollSnapBase.cs
index a890a78..295c1e5 100644
--- a/Scripts/Layout/ScrollSnapBase.cs
+++ b/Scripts/Layout/ScrollSnapBase.cs
@@ -46,12 +46,12 @@ namespace UnityEngine.UI.Extensions
[Tooltip("The gameobject that contains toggles which suggest pagination. (optional)")]
public GameObject Pagination;
- [Tooltip("Button to go to the next page. (optional)")]
- public GameObject NextButton;
-
[Tooltip("Button to go to the previous page. (optional)")]
public GameObject PrevButton;
+ [Tooltip("Button to go to the next page. (optional)")]
+ public GameObject NextButton;
+
[Tooltip("Transition speed between pages. (optional)")]
public float transitionSpeed = 7.5f;
@@ -84,7 +84,7 @@ namespace UnityEngine.UI.Extensions
_currentPage = value;
if(MaskArea) UpdateVisible();
if(!_lerp) ScreenChange();
- ChangeBulletsInfo(_currentPage);
+ OnCurrentScreenChange(_currentPage);
}
}
}
@@ -326,13 +326,23 @@ namespace UnityEngine.UI.Extensions
_lerp = true;
CurrentPage = GetPageforPosition(_screensContainer.localPosition);
GetPositionforPage(_currentPage, ref _lerp_target);
- ChangeBulletsInfo(_currentPage);
+ OnCurrentScreenChange(_currentPage);
}
+
+ ///
+ /// notifies pagination indicator and navigation buttons of a screen change
+ ///
+ internal void OnCurrentScreenChange(int currentScreen)
+ {
+ ChangeBulletsInfo(currentScreen);
+ ToggleNavigationButtons(currentScreen);
+ }
+
///
/// changes the bullets on the bottom of the page - pagination
///
///
- internal void ChangeBulletsInfo(int targetScreen)
+ private void ChangeBulletsInfo(int targetScreen)
{
if (Pagination)
for (int i = 0; i < Pagination.transform.childCount; i++)
@@ -343,6 +353,19 @@ namespace UnityEngine.UI.Extensions
}
}
+ ///
+ /// disables the page navigation buttons when at the first or last screen
+ ///
+ ///
+ private void ToggleNavigationButtons(int targetScreen) {
+ if (PrevButton) {
+ PrevButton.GetComponent