Allow ignoring the Time.timeScale on ScrollSnaps (Horiz + Vert)

pull/413/head
Rubén Moraleda 2019-01-15 11:25:12 +01:00 committed by Ruben Moraleda
parent f643e868d1
commit 67aefea569
3 changed files with 8 additions and 5 deletions

View File

@ -35,7 +35,7 @@ namespace UnityEngine.UI.Extensions
} }
else if (_lerp) 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) if (Vector3.Distance(_screensContainer.localPosition, _lerp_target) < 0.1f)
{ {
_screensContainer.localPosition = _lerp_target; _screensContainer.localPosition = _lerp_target;

View File

@ -76,6 +76,9 @@ namespace UnityEngine.UI.Extensions
[Tooltip("Speed at which the ScrollRect will keep scrolling before slowing down and stopping (optional)")] [Tooltip("Speed at which the ScrollRect will keep scrolling before slowing down and stopping (optional)")]
public int SwipeVelocityThreshold = 100; 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)")] [Tooltip("The visible bounds area, controls which items are visible/enabled. *Note Should use a RectMask. (optional)")]
public RectTransform MaskArea; public RectTransform MaskArea;

View File

@ -35,7 +35,7 @@ namespace UnityEngine.UI.Extensions
} }
else if (_lerp) 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) if (Vector3.Distance(_screensContainer.localPosition, _lerp_target) < 0.1f)
{ {
_screensContainer.localPosition = _lerp_target; _screensContainer.localPosition = _lerp_target;