Skip to content
Permalink
Browse files

Fixed issues with Time.timeScale = 0.

  • Loading branch information...
valyard committed Jul 29, 2017
1 parent 283e2b6 commit 89e846e1008fa9cea6f2b04f3a6619b8823bc59c
@@ -49,7 +49,7 @@ private void Update()
{
case PlanetStatus.Free:
transform.RotateAround(transform.parent.position, Vector3.up,
Speed*Time.deltaTime/transform.localPosition.sqrMagnitude);
Speed * Time.unscaledDeltaTime / transform.localPosition.sqrMagnitude);
break;
case PlanetStatus.Manual:
break;
@@ -60,7 +60,7 @@ private void Update()
break;
}

transform.Rotate(0, 0, Time.deltaTime*RotationSpeed);
transform.Rotate(0, 0, Time.unscaledDeltaTime * RotationSpeed);
}

void pressedhandler(object sender, System.EventArgs e)
@@ -13,7 +13,7 @@ public class Rotator : MonoBehaviour

void Update()
{
transform.localRotation *= Quaternion.Euler(0, 0, Time.deltaTime*RotationSpeed);
transform.localRotation *= Quaternion.Euler(0, 0, Time.unscaledDeltaTime * RotationSpeed);
}
}
}
@@ -3,8 +3,7 @@
* Based on http://pastebin.com/69QP1s45
*/


#if TOUCHSCRIPT_DEBUG
#if TOUCHSCRIPT_DEBUG

using System.Collections;
using System.Collections.Generic;
@@ -603,7 +602,7 @@ public float Draw()
{
Lines[i].Draw();
}
return Duration - Time.deltaTime;
return Duration - Time.unscaledDeltaTime;
}
}

@@ -149,11 +149,11 @@ protected void LateUpdate()
deltaSequence.Add(ScreenPosition - PreviousScreenPosition);
}

[ContextMenu("Basic Editor")]
private void switchToBasicEditor()
{
basicEditor = true;
}
[ContextMenu("Basic Editor")]
private void switchToBasicEditor()
{
basicEditor = true;
}

#endregion

@@ -209,7 +209,7 @@ protected override void pointersReleased(IList<Pointer> pointers)
deltaSequence.Add(ScreenPosition - PreviousScreenPosition);

float lastTime;
var deltas = deltaSequence.FindElementsLaterThan(Time.time - FlickTime, out lastTime);
var deltas = deltaSequence.FindElementsLaterThan(Time.unscaledTime - FlickTime, out lastTime);
var totalMovement = Vector2.zero;
var count = deltas.Count;
for (var i = 0; i < count; i++) totalMovement += deltas[i];
@@ -231,7 +231,7 @@ protected override void pointersReleased(IList<Pointer> pointers)
else
{
ScreenFlickVector = totalMovement;
ScreenFlickTime = Time.time - lastTime;
ScreenFlickTime = Time.unscaledTime - lastTime;
setState(GestureState.Recognized);
}
}
@@ -45,7 +45,7 @@ public class TapGesture : Gesture
/// <summary>
/// Unity event, occurs when gesture is recognized.
/// </summary>
public GestureEvent OnTap = new GestureEvent();
public GestureEvent OnTap = new GestureEvent();

#endregion

@@ -97,20 +97,20 @@ public float DistanceLimit
/// At the end of a gesture when pointers are lifted off due to the fact that computers are faster than humans the very last pointer's position will be gesture's <see cref="Gesture.ScreenPosition"/> after that. This flag is used to combine several pointers which from the point of a user were lifted off simultaneously and set their centroid as gesture's <see cref="Gesture.ScreenPosition"/>.
/// </remarks>
public bool CombinePointers
{
get { return combinePointers; }
set { combinePointers = value; }
}
{
get { return combinePointers; }
set { combinePointers = value; }
}

/// <summary>
/// Gets or sets time interval before gesture is recognized to combine all lifted pointers into a cluster to use its center as <see cref="Gesture.ScreenPosition"/>.
/// </summary>
/// <value> Time in seconds to treat pointers lifted off during this interval as a single gesture. </value>
public float CombinePointersInterval
{
get { return combinePointersInterval; }
set { combinePointersInterval = value; }
}
{
get { return combinePointersInterval; }
set { combinePointersInterval = value; }
}

#endregion

@@ -127,12 +127,12 @@ public float CombinePointersInterval
[NullToggle(NullFloatValue = float.PositiveInfinity)]
private float distanceLimit = float.PositiveInfinity;

[SerializeField]
[ToggleLeft]
private bool combinePointers = false;
[SerializeField]
[ToggleLeft]
private bool combinePointers = false;

[SerializeField]
private float combinePointersInterval = .3f;
[SerializeField]
private float combinePointersInterval = .3f;

private float distanceLimitInPixelsSquared;

@@ -146,18 +146,18 @@ public float CombinePointersInterval

#endregion

#region Public methods
#region Public methods

/// <inheritdoc />
public override bool ShouldReceivePointer(Pointer pointer)
{
if (!base.ShouldReceivePointer(pointer)) return false;
// Ignore redispatched pointers — they come from 2+ pointer gestures when one is left with 1 pointer.
// In this state it means that the user doesn't have an intention to tap the object.
return (pointer.Flags & Pointer.FLAG_RETURNED) == 0;
}
/// <inheritdoc />
public override bool ShouldReceivePointer(Pointer pointer)
{
if (!base.ShouldReceivePointer(pointer)) return false;
// Ignore redispatched pointers — they come from 2+ pointer gestures when one is left with 1 pointer.
// In this state it means that the user doesn't have an intention to tap the object.
return (pointer.Flags & Pointer.FLAG_RETURNED) == 0;
}

#endregion
#endregion

#region Unity methods

@@ -170,10 +170,10 @@ protected override void OnEnable()
}

[ContextMenu("Basic Editor")]
private void switchToBasicEditor()
{
basicEditor = true;
}
private void switchToBasicEditor()
{
basicEditor = true;
}

#endregion

@@ -246,43 +246,43 @@ protected override void pointersReleased(IList<Pointer> pointers)
{
base.pointersReleased(pointers);

if (combinePointers)
{
if (combinePointers)
{
var count = pointers.Count;
for (var i = 0; i < count; i++) pointerSequence.Add(pointers[i]);

if (NumPointers == 0)
{
// Checking which points were removed in clusterExistenceTime seconds to set their centroid as cached screen position
var cluster = pointerSequence.FindElementsLaterThan(Time.time - combinePointersInterval, shouldCachePointerPosition);
cachedScreenPosition = ClusterUtils.Get2DCenterPosition(cluster);
cachedPreviousScreenPosition = ClusterUtils.GetPrevious2DCenterPosition(cluster);
}
}
else
{
if (NumPointers == 0)
{
if (!isActive)
{
setState(GestureState.Failed);
return;
}

// pointers outside of gesture target are ignored in shouldCachePointerPosition()
// if all pointers are outside ScreenPosition will be invalid
if (TouchManager.IsInvalidPosition(ScreenPosition))
{
setState(GestureState.Failed);
}
else
{
tapsDone++;
isActive = false;
if (tapsDone >= numberOfTapsRequired) setState(GestureState.Recognized);
}
}
}
for (var i = 0; i < count; i++) pointerSequence.Add(pointers[i]);

if (NumPointers == 0)
{
// Checking which points were removed in clusterExistenceTime seconds to set their centroid as cached screen position
var cluster = pointerSequence.FindElementsLaterThan(Time.unscaledTime - combinePointersInterval, shouldCachePointerPosition);
cachedScreenPosition = ClusterUtils.Get2DCenterPosition(cluster);
cachedPreviousScreenPosition = ClusterUtils.GetPrevious2DCenterPosition(cluster);
}
}
else
{
if (NumPointers == 0)
{
if (!isActive)
{
setState(GestureState.Failed);
return;
}

// pointers outside of gesture target are ignored in shouldCachePointerPosition()
// if all pointers are outside ScreenPosition will be invalid
if (TouchManager.IsInvalidPosition(ScreenPosition))
{
setState(GestureState.Failed);
}
else
{
tapsDone++;
isActive = false;
if (tapsDone >= numberOfTapsRequired) setState(GestureState.Recognized);
}
}
}
}

/// <inheritdoc />
@@ -293,7 +293,7 @@ protected override void onRecognized()
StopCoroutine("wait");
if (tappedInvoker != null) tappedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
if (UseSendMessage && SendMessageTarget != null) SendMessageTarget.SendMessage(TAP_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
if (UseUnityEvents) OnTap.Invoke(this);
if (UseUnityEvents) OnTap.Invoke(this);
}

/// <inheritdoc />
@@ -15,7 +15,7 @@ internal sealed class TimedSequence<T>

public void Add(T element)
{
Add(element, Time.time);
Add(element, Time.unscaledTime);
}

public void Add(T element, float time)

0 comments on commit 89e846e

Please sign in to comment.
You can’t perform that action at this time.