From 966f82da3f58a3f27c09655eb3ed659344e4160d Mon Sep 17 00:00:00 2001 From: Simon Jackson Date: Sun, 12 Mar 2017 15:29:59 +0000 Subject: [PATCH] Added option to NOT restart control Also switched to the InitialiseChildObjectsFromScene (whoops) --- Scripts/Layout/HorizontalScrollSnap.cs | 6 +++--- Scripts/Layout/ScrollSnapBase.cs | 3 +++ Scripts/Layout/VerticalScrollSnap.cs | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Scripts/Layout/HorizontalScrollSnap.cs b/Scripts/Layout/HorizontalScrollSnap.cs index bea5cf8..00488a9 100644 --- a/Scripts/Layout/HorizontalScrollSnap.cs +++ b/Scripts/Layout/HorizontalScrollSnap.cs @@ -195,12 +195,12 @@ namespace UnityEngine.UI.Extensions private void OnEnable() { - InitialiseChildObjects(); + InitialiseChildObjectsFromScene(); DistributePages(); if (MaskArea) UpdateVisible(); - if(JumpOnEnable) SetScrollContainerPosition(); - GoToScreen(StartingScreen); + if (JumpOnEnable || !RestartOnEnable) SetScrollContainerPosition(); + if (RestartOnEnable) GoToScreen(StartingScreen); } #region Interfaces diff --git a/Scripts/Layout/ScrollSnapBase.cs b/Scripts/Layout/ScrollSnapBase.cs index 49bc145..f4e1581 100644 --- a/Scripts/Layout/ScrollSnapBase.cs +++ b/Scripts/Layout/ScrollSnapBase.cs @@ -93,6 +93,9 @@ namespace UnityEngine.UI.Extensions [Tooltip("By default the container will lerp to the start when enabled in the scene, this option overrides this and forces it to simply jump without lerping")] public bool JumpOnEnable = false; + [Tooltip("By default the container will return to the original starting page when enabled, this option overrides this behaviour and stays on the current selection")] + public bool RestartOnEnable = false; + [Tooltip("(Experimental)\nBy default, child array objects will use the parent transform\nHowever you can disable this for some interesting effects")] public bool UseParentTransform = true; diff --git a/Scripts/Layout/VerticalScrollSnap.cs b/Scripts/Layout/VerticalScrollSnap.cs index 663dfb7..c150756 100644 --- a/Scripts/Layout/VerticalScrollSnap.cs +++ b/Scripts/Layout/VerticalScrollSnap.cs @@ -195,12 +195,12 @@ namespace UnityEngine.UI.Extensions private void OnEnable() { - InitialiseChildObjects(); + InitialiseChildObjectsFromScene(); DistributePages(); if (MaskArea) UpdateVisible(); - if (JumpOnEnable) SetScrollContainerPosition(); - GoToScreen(StartingScreen); + if (JumpOnEnable || !RestartOnEnable) SetScrollContainerPosition(); + if(RestartOnEnable) GoToScreen(StartingScreen); } #region Interfaces