mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2026-02-15 19:41:37 +08:00
[BUGFIX] Fixed issue where timeScale-independent tweens would resume incorrectly after the player was paused
This commit is contained in:
parent
a88db1b6b0
commit
63065aa105
@ -356,6 +356,9 @@
|
|||||||
<summary>Default period used for eases
|
<summary>Default period used for eases
|
||||||
<para>Default: 0</para></summary>
|
<para>Default: 0</para></summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="F:DG.Tweening.DOTween.instance">
|
||||||
|
<summary>Used internally. Assigned/removed by DOTweenComponent.Create/DestroyInstance</summary>
|
||||||
|
</member>
|
||||||
<member name="M:DG.Tweening.DOTween.Init(System.Nullable{System.Boolean},System.Nullable{System.Boolean},System.Nullable{DG.Tweening.LogBehaviour})">
|
<member name="M:DG.Tweening.DOTween.Init(System.Nullable{System.Boolean},System.Nullable{System.Boolean},System.Nullable{DG.Tweening.LogBehaviour})">
|
||||||
<summary>
|
<summary>
|
||||||
Must be called once, before the first ever DOTween call/reference,
|
Must be called once, before the first ever DOTween call/reference,
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -35,8 +35,21 @@ namespace DG.Tweening
|
|||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
DOTweenExternalCommand.SetOrientationOnPath += Physics.SetOrientationOnPath;
|
DOTweenExternalCommand.SetOrientationOnPath += Physics.SetOrientationOnPath;
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
UnityEditor.EditorApplication.playmodeStateChanged += PlaymodeStateChanged;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
// Fires OnApplicationPause in DOTweenComponent even when Editor is paused (otherwise it's only fired at runtime)
|
||||||
|
static void PlaymodeStateChanged()
|
||||||
|
{
|
||||||
|
if (DOTween.instance == null) return;
|
||||||
|
DOTween.instance.OnApplicationPause(UnityEditor.EditorApplication.isPaused);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||||
// ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████
|
// ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████
|
||||||
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||||
|
|||||||
30
UnityTests.Unity5/Assets/_Tests/UnityPausingAndTime.cs
Normal file
30
UnityTests.Unity5/Assets/_Tests/UnityPausingAndTime.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using DG.Tweening;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class UnityPausingAndTime : BrainBase
|
||||||
|
{
|
||||||
|
public Transform independentTarget;
|
||||||
|
public Transform target;
|
||||||
|
|
||||||
|
IEnumerator Start()
|
||||||
|
{
|
||||||
|
Debug.Log("real: " + Time.realtimeSinceStartup + " - unscaled: " + Time.unscaledTime + "/" + Time.unscaledDeltaTime);
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(1);
|
||||||
|
|
||||||
|
Debug.Log("real: " + Time.realtimeSinceStartup + " - unscaled: " + Time.unscaledTime + "/" + Time.unscaledDeltaTime);
|
||||||
|
|
||||||
|
float startTime0 = Time.realtimeSinceStartup;
|
||||||
|
float startTime1 = Time.unscaledTime;
|
||||||
|
|
||||||
|
independentTarget.DOMoveX(3, 2f).SetUpdate(true).SetEase(Ease.Linear)
|
||||||
|
.OnComplete(() => {
|
||||||
|
Debug.Log("real: " + Time.realtimeSinceStartup + " ► " + (Time.realtimeSinceStartup - startTime0));
|
||||||
|
Debug.Log("unscaled: " + Time.unscaledTime + " ► " + (Time.unscaledTime - startTime1));
|
||||||
|
});
|
||||||
|
|
||||||
|
target.DOMoveX(3, 2f).SetEase(Ease.Linear);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
UnityTests.Unity5/Assets/_Tests/UnityPausingAndTime.cs.meta
Normal file
12
UnityTests.Unity5/Assets/_Tests/UnityPausingAndTime.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4f6149ef7db2fad4183fc40bc7fa90f2
|
||||||
|
timeCreated: 1534507942
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
UnityTests.Unity5/Assets/_Tests/UnityPausingAndTime.unity
Normal file
BIN
UnityTests.Unity5/Assets/_Tests/UnityPausingAndTime.unity
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 08a4033c80a777a41876577a65aefd96
|
||||||
|
timeCreated: 1534507937
|
||||||
|
licenseType: Pro
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@ -25,6 +25,8 @@ namespace DG.Tweening.Core
|
|||||||
float _unscaledTime;
|
float _unscaledTime;
|
||||||
float _unscaledDeltaTime;
|
float _unscaledDeltaTime;
|
||||||
|
|
||||||
|
float _pausedTime; // Marks the time when Unity was paused
|
||||||
|
|
||||||
bool _duplicateToDestroy;
|
bool _duplicateToDestroy;
|
||||||
|
|
||||||
#region Unity Methods
|
#region Unity Methods
|
||||||
@ -130,11 +132,27 @@ namespace DG.Tweening.Core
|
|||||||
if (DOTween.instance == this) DOTween.instance = null;
|
if (DOTween.instance == this) DOTween.instance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detract/reapply pause time from/to unscaled time
|
||||||
|
public void OnApplicationPause(bool pauseStatus)
|
||||||
|
{
|
||||||
|
if (pauseStatus) {
|
||||||
|
_pausedTime = Time.realtimeSinceStartup;
|
||||||
|
} else {
|
||||||
|
_unscaledTime += Time.realtimeSinceStartup - _pausedTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OnApplicationQuit()
|
void OnApplicationQuit()
|
||||||
{
|
{
|
||||||
DOTween.isQuitting = true;
|
DOTween.isQuitting = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Editor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|||||||
@ -32,7 +32,7 @@ namespace DG.Tweening
|
|||||||
public class DOTween
|
public class DOTween
|
||||||
{
|
{
|
||||||
/// <summary>DOTween's version</summary>
|
/// <summary>DOTween's version</summary>
|
||||||
public static readonly string Version = "1.2.110"; // Last version before modules: 1.1.755
|
public static readonly string Version = "1.2.120"; // Last version before modules: 1.1.755
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
// Options ////////////////////////////////////
|
// Options ////////////////////////////////////
|
||||||
@ -103,7 +103,9 @@ namespace DG.Tweening
|
|||||||
/// <para>Default: 0</para></summary>
|
/// <para>Default: 0</para></summary>
|
||||||
public static float defaultEasePeriod = 0;
|
public static float defaultEasePeriod = 0;
|
||||||
|
|
||||||
internal static DOTweenComponent instance; // Assigned/removed by DOTweenComponent.Create/DestroyInstance
|
/// <summary>Used internally. Assigned/removed by DOTweenComponent.Create/DestroyInstance</summary>
|
||||||
|
public static DOTweenComponent instance;
|
||||||
|
|
||||||
internal static int maxActiveTweenersReached, maxActiveSequencesReached; // Controlled by DOTweenInspector if showUnityEditorReport is active
|
internal static int maxActiveTweenersReached, maxActiveSequencesReached; // Controlled by DOTweenInspector if showUnityEditorReport is active
|
||||||
internal static readonly List<TweenCallback> GizmosDelegates = new List<TweenCallback>(); // Can be used by other classes to call internal gizmo draw methods
|
internal static readonly List<TweenCallback> GizmosDelegates = new List<TweenCallback>(); // Can be used by other classes to call internal gizmo draw methods
|
||||||
internal static bool initialized; // Can be set to false by DOTweenComponent OnDestroy
|
internal static bool initialized; // Can be set to false by DOTweenComponent OnDestroy
|
||||||
|
|||||||
@ -356,6 +356,9 @@
|
|||||||
<summary>Default period used for eases
|
<summary>Default period used for eases
|
||||||
<para>Default: 0</para></summary>
|
<para>Default: 0</para></summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="F:DG.Tweening.DOTween.instance">
|
||||||
|
<summary>Used internally. Assigned/removed by DOTweenComponent.Create/DestroyInstance</summary>
|
||||||
|
</member>
|
||||||
<member name="M:DG.Tweening.DOTween.Init(System.Nullable{System.Boolean},System.Nullable{System.Boolean},System.Nullable{DG.Tweening.LogBehaviour})">
|
<member name="M:DG.Tweening.DOTween.Init(System.Nullable{System.Boolean},System.Nullable{System.Boolean},System.Nullable{DG.Tweening.LogBehaviour})">
|
||||||
<summary>
|
<summary>
|
||||||
Must be called once, before the first ever DOTween call/reference,
|
Must be called once, before the first ever DOTween call/reference,
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -35,8 +35,21 @@ namespace DG.Tweening
|
|||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
DOTweenExternalCommand.SetOrientationOnPath += Physics.SetOrientationOnPath;
|
DOTweenExternalCommand.SetOrientationOnPath += Physics.SetOrientationOnPath;
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
UnityEditor.EditorApplication.playmodeStateChanged += PlaymodeStateChanged;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
// Fires OnApplicationPause in DOTweenComponent even when Editor is paused (otherwise it's only fired at runtime)
|
||||||
|
static void PlaymodeStateChanged()
|
||||||
|
{
|
||||||
|
if (DOTween.instance == null) return;
|
||||||
|
DOTween.instance.OnApplicationPause(UnityEditor.EditorApplication.isPaused);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||||
// ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████
|
// ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████
|
||||||
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user