1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 17:26:03 +08:00

[BUGFIX] Fixed OnComplete being called twice if tween.Complete was fired inside an OnUpdate call

This commit is contained in:
Demigiant 2017-12-04 21:39:13 +01:00
parent 0ea3c4bf19
commit c21989e786
45 changed files with 16 additions and 6 deletions

View File

@ -17,7 +17,11 @@ public class TempTests : BrainBase
{ {
yield return new WaitForSeconds(0.8f); yield return new WaitForSeconds(0.8f);
Tween t = target.DOShakeRotation(5f, new Vector3(0f, 20f, 20f), 4, 10f, true); Tween t = target.DOMoveX(2, 2);
// Tween t = target.DOPunchRotation(new Vector3(0f, 0f, 20f), 5, 10); // t.OnUpdate(t.Complete);
t.OnComplete(()=> Debug.Log("COMPLETE"));
yield return new WaitForSeconds(0.4f);
t.Complete();
} }
} }

View File

@ -10,6 +10,9 @@ namespace DG.Tweening.Core.Enums
{ {
Update, Update,
Goto, // Treats update as a full goto, thus not calling eventual onStepComplete callbacks Goto, // Treats update as a full goto, thus not calling eventual onStepComplete callbacks
IgnoreOnUpdate // Ignores OnUpdate callback (used when applying some ChangeValue during an OnUpdate call) IgnoreOnUpdate, // Ignores OnUpdate callback (used when applying some ChangeValue during an OnUpdate call)
// Set by tween.Complete extension, if OnComplete is fired manually during an updateLoop,
// so it will not be fired twice (since it will already be fired by the Update loop)
IgnoreOnComplete
} }
} }

View File

@ -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.1.680"; public static readonly string Version = "1.1.685";
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Options //////////////////////////////////// // Options ////////////////////////////////////

View File

@ -254,7 +254,7 @@ namespace DG.Tweening
if (newCompletedSteps > 0 && updateMode == UpdateMode.Update && t.onStepComplete != null) { if (newCompletedSteps > 0 && updateMode == UpdateMode.Update && t.onStepComplete != null) {
for (int i = 0; i < newCompletedSteps; ++i) OnTweenCallback(t.onStepComplete); for (int i = 0; i < newCompletedSteps; ++i) OnTweenCallback(t.onStepComplete);
} }
if (t.isComplete && !wasComplete && t.onComplete != null) { if (t.isComplete && !wasComplete && updateMode != UpdateMode.IgnoreOnComplete && t.onComplete != null) {
OnTweenCallback(t.onComplete); OnTweenCallback(t.onComplete);
} }
if (!t.isPlaying && wasPlaying && (!t.isComplete || !t.autoKill) && t.onPause != null) { if (!t.isPlaying && wasPlaying && (!t.isComplete || !t.autoKill) && t.onPause != null) {

View File

@ -55,7 +55,10 @@ namespace DG.Tweening
if (Debugger.logPriority > 1) Debugger.LogNestedTween(t); return; if (Debugger.logPriority > 1) Debugger.LogNestedTween(t); return;
} }
TweenManager.Complete(t, true, withCallbacks ? UpdateMode.Update : UpdateMode.Goto); // TweenManager.Complete(t, true, withCallbacks ? UpdateMode.Update : UpdateMode.Goto);
UpdateMode updateMode = TweenManager.isUpdateLoop ? UpdateMode.IgnoreOnComplete
: withCallbacks ? UpdateMode.Update : UpdateMode.Goto;
TweenManager.Complete(t, true, updateMode);
} }
/// <summary>Flips the direction of this tween (backwards if it was going forward or viceversa)</summary> /// <summary>Flips the direction of this tween (backwards if it was going forward or viceversa)</summary>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.