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