From 67aefea569120b237e8eb25b4050541eccf7b90a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rub=C3=A9n=20Moraleda?= <ruben.moraleda.ruano@gmail.com>
Date: Tue, 15 Jan 2019 11:25:12 +0100
Subject: [PATCH] Allow ignoring the Time.timeScale on ScrollSnaps (Horiz +
 Vert)

---
 Scripts/Layout/HorizontalScrollSnap.cs | 4 ++--
 Scripts/Layout/ScrollSnapBase.cs       | 5 ++++-
 Scripts/Layout/VerticalScrollSnap.cs   | 4 ++--
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Scripts/Layout/HorizontalScrollSnap.cs b/Scripts/Layout/HorizontalScrollSnap.cs
index 54b4a02..74e0e64 100644
--- a/Scripts/Layout/HorizontalScrollSnap.cs
+++ b/Scripts/Layout/HorizontalScrollSnap.cs
@@ -35,7 +35,7 @@ namespace UnityEngine.UI.Extensions
             }
             else if (_lerp)
             {
-                _screensContainer.localPosition = Vector3.Lerp(_screensContainer.localPosition, _lerp_target, transitionSpeed * Time.deltaTime);
+                _screensContainer.localPosition = Vector3.Lerp(_screensContainer.localPosition, _lerp_target, transitionSpeed * (UseTimeScale ? Time.deltaTime : Time.unscaledDeltaTime));
                 if (Vector3.Distance(_screensContainer.localPosition, _lerp_target) < 0.1f)
                 {
                     _screensContainer.localPosition = _lerp_target;
@@ -292,4 +292,4 @@ namespace UnityEngine.UI.Extensions
         }
         #endregion
     }
-}
\ No newline at end of file
+}
diff --git a/Scripts/Layout/ScrollSnapBase.cs b/Scripts/Layout/ScrollSnapBase.cs
index 6829fa7..4b1a8aa 100644
--- a/Scripts/Layout/ScrollSnapBase.cs
+++ b/Scripts/Layout/ScrollSnapBase.cs
@@ -76,6 +76,9 @@ namespace UnityEngine.UI.Extensions
         [Tooltip("Speed at which the ScrollRect will keep scrolling before slowing down and stopping (optional)")]
         public int SwipeVelocityThreshold = 100;
 
+	[Tooltip("Use time scale instead of unscaled time (optional)")]
+	public Boolean UseTimeScale = true;
+
         [Tooltip("The visible bounds area, controls which items are visible/enabled. *Note Should use a RectMask. (optional)")]
         public RectTransform MaskArea;
 
@@ -592,4 +595,4 @@ namespace UnityEngine.UI.Extensions
         }
         #endregion
     }
-}
\ No newline at end of file
+}
diff --git a/Scripts/Layout/VerticalScrollSnap.cs b/Scripts/Layout/VerticalScrollSnap.cs
index 7599eca..4c9167c 100644
--- a/Scripts/Layout/VerticalScrollSnap.cs
+++ b/Scripts/Layout/VerticalScrollSnap.cs
@@ -35,7 +35,7 @@ namespace UnityEngine.UI.Extensions
             }
             else if (_lerp)
             {
-                _screensContainer.localPosition = Vector3.Lerp(_screensContainer.localPosition, _lerp_target, transitionSpeed * Time.deltaTime);
+                _screensContainer.localPosition = Vector3.Lerp(_screensContainer.localPosition, _lerp_target, transitionSpeed * (UseTimeScale ? Time.deltaTime : Time.unscaledDeltaTime));
                 if (Vector3.Distance(_screensContainer.localPosition, _lerp_target) < 0.1f)
                 {
                     _screensContainer.localPosition = _lerp_target;
@@ -291,4 +291,4 @@ namespace UnityEngine.UI.Extensions
         }
         #endregion
     }
-}
\ No newline at end of file
+}