From 006ad7311fd6bf49b71b2a1b220b05350dbd633a Mon Sep 17 00:00:00 2001 From: Simon Jackson Date: Thu, 21 Jul 2016 17:25:34 +0100 Subject: [PATCH] H & V Scroll snap fixes to resolve #91 --HG-- branch : develop_5.3 --- Scripts/Layout/HorizontalScrollSnap.cs | 11 ++++++----- Scripts/Layout/VerticalScrollSnap.cs | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Scripts/Layout/HorizontalScrollSnap.cs b/Scripts/Layout/HorizontalScrollSnap.cs index 8800843..cdbe371 100644 --- a/Scripts/Layout/HorizontalScrollSnap.cs +++ b/Scripts/Layout/HorizontalScrollSnap.cs @@ -43,13 +43,14 @@ namespace UnityEngine.UI.Extensions private Vector3 _startPosition = new Vector3(); [Tooltip("The currently active page")] - [SerializeField] private int _currentScreen; [Tooltip("The screen / page to start the control on")] + [SerializeField] public int StartingScreen = 1; [Tooltip("The distance between two pages, by default 3 times the height of the control")] + [SerializeField] public int PageStep = 0; public int CurrentPage @@ -268,13 +269,13 @@ namespace UnityEngine.UI.Extensions void OnValidate() { var childCount = gameObject.GetComponent().content.childCount; - if (StartingScreen > childCount) + if (StartingScreen > childCount - 1) { - StartingScreen = childCount; + StartingScreen = childCount - 1; } - if (StartingScreen < 1) + if (StartingScreen < 0) { - StartingScreen = 1; + StartingScreen = 0; } } diff --git a/Scripts/Layout/VerticalScrollSnap.cs b/Scripts/Layout/VerticalScrollSnap.cs index 78d525c..d0a25d8 100644 --- a/Scripts/Layout/VerticalScrollSnap.cs +++ b/Scripts/Layout/VerticalScrollSnap.cs @@ -42,13 +42,14 @@ namespace UnityEngine.UI.Extensions private Vector3 _startPosition = new Vector3(); [Tooltip("The currently active page")] - [SerializeField] private int _currentScreen; [Tooltip("The screen / page to start the control on")] + [SerializeField] public int StartingScreen = 1; [Tooltip("The distance between two pages, by default 3 times the width of the control")] + [SerializeField] public int PageStep = 0; public int CurrentPage @@ -266,13 +267,13 @@ namespace UnityEngine.UI.Extensions void OnValidate() { var childCount = gameObject.GetComponent().content.childCount; - if (StartingScreen > childCount) + if (StartingScreen > childCount - 1) { - StartingScreen = childCount; + StartingScreen = childCount - 1; } - if (StartingScreen < 1) + if (StartingScreen < 0) { - StartingScreen = 1; + StartingScreen = 0; } }