1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2026-02-12 18:18:56 +08:00

Fixed error generated by calling KillAll from inside an OnComplete callback

This commit is contained in:
Demigiant 2016-04-03 14:24:06 +02:00
parent 2a8e7cc55c
commit 8718c07287
43 changed files with 15 additions and 4 deletions

View File

@ -30,6 +30,7 @@ public class IndexOutOfRangeReproduced : BrainBase
totCreatedTweens++; totCreatedTweens++;
Tween t = target.DOMove(new Vector3(1, 1), 0.5f); Tween t = target.DOMove(new Vector3(1, 1), 0.5f);
if (i == 49) t.OnComplete(()=> DOTween.KillAll()); if (i == 49) t.OnComplete(()=> DOTween.KillAll());
t.Goto(100);
} }
} }

View File

@ -40,6 +40,9 @@ namespace DG.Tweening.Core
static int _minPooledTweenerId = -1; // Lowest PooledTweeners id that is actually full static int _minPooledTweenerId = -1; // Lowest PooledTweeners id that is actually full
static int _maxPooledTweenerId = -1; // Highest PooledTweeners id that is actually full static int _maxPooledTweenerId = -1; // Highest PooledTweeners id that is actually full
// Used to prevent tweens from being re-killed at the end of an update loop if KillAll was called during said loop
static bool _despawnAllCalledFromUpdateLoopCallback;
#if DEBUG #if DEBUG
static public int updateLoopCount; static public int updateLoopCount;
#endif #endif
@ -180,6 +183,8 @@ namespace DG.Tweening.Core
_maxActiveLookupId = _reorganizeFromId = -1; _maxActiveLookupId = _reorganizeFromId = -1;
_requiresActiveReorganization = false; _requiresActiveReorganization = false;
if (isUpdateLoop) _despawnAllCalledFromUpdateLoopCallback = true;
return totDespawned; return totDespawned;
} }
@ -401,9 +406,14 @@ namespace DG.Tweening.Core
} }
// Kill all eventually marked tweens // Kill all eventually marked tweens
if (willKill) { if (willKill) {
DespawnTweens(_KillList, false); if (_despawnAllCalledFromUpdateLoopCallback) {
int count = _KillList.Count - 1; // Do not despawn tweens again, since Kill/DespawnAll was already called
for (int i = count; i > -1; --i) RemoveActiveTween(_KillList[i]); _despawnAllCalledFromUpdateLoopCallback = false;
} else {
DespawnTweens(_KillList, false);
int count = _KillList.Count - 1;
for (int i = count; i > -1; --i) RemoveActiveTween(_KillList[i]);
}
_KillList.Clear(); _KillList.Clear();
} }
isUpdateLoop = false; isUpdateLoop = false;

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.250"; public static readonly string Version = "1.1.260";
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Options //////////////////////////////////// // Options ////////////////////////////////////

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.