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

[BUGFIX] Fixed IndexOutOfRange exception happening when a Kill(complete) causes multiple tweens to be killed via nested OnComplete callbacks

This commit is contained in:
Demigiant 2017-10-10 13:21:10 +02:00
parent c4366240e1
commit 6a0e92ce7e
16 changed files with 70 additions and 20 deletions

View File

@ -1778,6 +1778,17 @@
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="mode">Rotation mode</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendablePunchRotation(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Int32,System.Single)">
<summary>Punches a Transform's localRotation BY the given value and then back to the starting one
as if it was connected to the starting rotation via an elastic. Does it in a way that allows other
DOBlendableRotate tweens to work together on the same target</summary>
<param name="punch">The punch strength (added to the Transform's current rotation)</param>
<param name="duration">The duration of the tween</param>
<param name="vibrato">Indicates how much will the punch vibrate</param>
<param name="elasticity">Represents how much (0 to 1) the vector will go beyond the starting rotation when bouncing backwards.
1 creates a full oscillation between the punch rotation and the opposite rotation,
while 0 oscillates only between the punch and the start rotation</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableScaleBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single)">
<summary>Tweens a Transform's localScale BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableScale tweens to work together on the same target,

View File

@ -1778,6 +1778,17 @@
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="mode">Rotation mode</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendablePunchRotation(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Int32,System.Single)">
<summary>Punches a Transform's localRotation BY the given value and then back to the starting one
as if it was connected to the starting rotation via an elastic. Does it in a way that allows other
DOBlendableRotate tweens to work together on the same target</summary>
<param name="punch">The punch strength (added to the Transform's current rotation)</param>
<param name="duration">The duration of the tween</param>
<param name="vibrato">Indicates how much will the punch vibrate</param>
<param name="elasticity">Represents how much (0 to 1) the vector will go beyond the starting rotation when bouncing backwards.
1 creates a full oscillation between the punch rotation and the opposite rotation,
while 0 oscillates only between the punch and the start rotation</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableScaleBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single)">
<summary>Tweens a Transform's localScale BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableScale tweens to work together on the same target,

View File

@ -1778,6 +1778,17 @@
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="mode">Rotation mode</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendablePunchRotation(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Int32,System.Single)">
<summary>Punches a Transform's localRotation BY the given value and then back to the starting one
as if it was connected to the starting rotation via an elastic. Does it in a way that allows other
DOBlendableRotate tweens to work together on the same target</summary>
<param name="punch">The punch strength (added to the Transform's current rotation)</param>
<param name="duration">The duration of the tween</param>
<param name="vibrato">Indicates how much will the punch vibrate</param>
<param name="elasticity">Represents how much (0 to 1) the vector will go beyond the starting rotation when bouncing backwards.
1 creates a full oscillation between the punch rotation and the opposite rotation,
while 0 oscillates only between the punch and the start rotation</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableScaleBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single)">
<summary>Tweens a Transform's localScale BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableScale tweens to work together on the same target,

View File

@ -5,30 +5,31 @@ using UnityEngine;
public class IndexOutOfRangeOnKill02 : MonoBehaviour
{
// Can't replicate the error
void Start()
public Transform target;
public RectTransform targetUI;
void Update()
{
Debug.Log("Start() ► Disabling safe mode");
DOTween.Init(false, false);
Tween t = transform.DOMoveX(2, 2);
t.OnComplete(() => {
Debug.Log("OnComplete()");
TweenKiller();
Destroy(gameObject);
});
if(Input.GetKeyUp(KeyCode.L)) ReproTweenBug();
}
void OnDestroy()
void ReproTweenBugKiller()
{
Debug.Log("OnDestroy()");
TweenKiller();
target.DOKill(true);
targetUI.DOKill(true);
}
void TweenKiller()
void ReproTweenBug()
{
Debug.Log("TweenKiller()");
transform.DOKill(true);
ReproTweenBugKiller();
var rotation = 2 * 360;
var duration = rotation / 360f;
target.DORotate(new Vector3(0, 0, rotation), duration, RotateMode.FastBeyond360).SetEase(Ease.OutCubic)
.OnComplete(() => {
targetUI.DOAnchorPos(Vector2.zero, 0.4f).SetEase(Ease.InBack)
.OnComplete(() => targetUI.DOKill(true));
});
}
}

View File

@ -576,7 +576,12 @@ namespace DG.Tweening.Core
// Special additional operations in case of despawn
if (hasDespawned) {
int count = _KillList.Count - 1;
for (int i = count; i > -1; --i) RemoveActiveTween(_KillList[i]);
for (int i = count; i > -1; --i) {
Tween t = _KillList[i];
// Ignore tweens with activeId -1, since they were already killed and removed
// by nested OnComplete callbacks
if (t.activeId != -1) RemoveActiveTween(t);
}
_KillList.Clear();
}

View File

@ -32,7 +32,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.1.655";
public static readonly string Version = "1.1.660";
///////////////////////////////////////////////
// Options ////////////////////////////////////

View File

@ -1778,6 +1778,17 @@
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
<param name="mode">Rotation mode</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendablePunchRotation(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Int32,System.Single)">
<summary>Punches a Transform's localRotation BY the given value and then back to the starting one
as if it was connected to the starting rotation via an elastic. Does it in a way that allows other
DOBlendableRotate tweens to work together on the same target</summary>
<param name="punch">The punch strength (added to the Transform's current rotation)</param>
<param name="duration">The duration of the tween</param>
<param name="vibrato">Indicates how much will the punch vibrate</param>
<param name="elasticity">Represents how much (0 to 1) the vector will go beyond the starting rotation when bouncing backwards.
1 creates a full oscillation between the punch rotation and the opposite rotation,
while 0 oscillates only between the punch and the start rotation</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableScaleBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single)">
<summary>Tweens a Transform's localScale BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableScale tweens to work together on the same target,

Binary file not shown.