mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-20 17:26:03 +08:00
[BUGFIX] Callbacks added to a Sequence now always respect the insertion order even if they're placed at the same exact time
This commit is contained in:
parent
a647318c24
commit
321780ba9b
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -25,8 +25,10 @@ public class EmptySequences : BrainBase
|
|||||||
if (createSequenceA) {
|
if (createSequenceA) {
|
||||||
a = DOTween.Sequence()
|
a = DOTween.Sequence()
|
||||||
.AppendCallback(() => Debug.Log("A callback 1/2"))
|
.AppendCallback(() => Debug.Log("A callback 1/2"))
|
||||||
// .AppendInterval(1f)
|
.AppendInterval(1f)
|
||||||
.AppendCallback(() => Debug.Log("A callback 2/2 (1 sec delay)"))
|
.AppendCallback(() => Debug.Log("A callback 2/2 (1 sec delay)"))
|
||||||
|
.InsertCallback(0, () => Debug.Log("A callback 0 A"))
|
||||||
|
.InsertCallback(0, () => Debug.Log("A callback 0 B"))
|
||||||
.OnStart(() => Debug.Log("A OnStart"))
|
.OnStart(() => Debug.Log("A OnStart"))
|
||||||
.OnStepComplete(() => Debug.Log("A OnStepComplete"))
|
.OnStepComplete(() => Debug.Log("A OnStepComplete"))
|
||||||
.OnComplete(() => Debug.Log("A OnComplete"))
|
.OnComplete(() => Debug.Log("A OnComplete"))
|
||||||
|
|||||||
Binary file not shown.
@ -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.065"; // Last version before modules: 1.1.755
|
public static readonly string Version = "1.2.070"; // Last version before modules: 1.1.755
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
// Options ////////////////////////////////////
|
// Options ////////////////////////////////////
|
||||||
|
|||||||
@ -166,7 +166,8 @@ namespace DG.Tweening
|
|||||||
s.startupDone = true;
|
s.startupDone = true;
|
||||||
s.fullDuration = s.loops > -1 ? s.duration * s.loops : Mathf.Infinity;
|
s.fullDuration = s.loops > -1 ? s.duration * s.loops : Mathf.Infinity;
|
||||||
// Order sequencedObjs by start position
|
// Order sequencedObjs by start position
|
||||||
s._sequencedObjs.Sort(SortSequencedObjs);
|
StableSortSequencedObjs(s._sequencedObjs);
|
||||||
|
// s._sequencedObjs.Sort(SortSequencedObjs); // Quicker old method that didn't implement stable sort
|
||||||
// Set relative nested tweens
|
// Set relative nested tweens
|
||||||
if (s.isRelative) {
|
if (s.isRelative) {
|
||||||
for (int len = s.sequencedTweens.Count, i = 0; i < len; ++i) {
|
for (int len = s.sequencedTweens.Count, i = 0; i < len; ++i) {
|
||||||
@ -347,11 +348,26 @@ namespace DG.Tweening
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SortSequencedObjs(ABSSequentiable a, ABSSequentiable b)
|
static void StableSortSequencedObjs(List<ABSSequentiable> list)
|
||||||
{
|
{
|
||||||
if (a.sequencedPosition > b.sequencedPosition) return 1;
|
int len = list.Count;
|
||||||
if (a.sequencedPosition < b.sequencedPosition) return -1;
|
for (int i = 1; i < len; i++) {
|
||||||
return 0;
|
int j = i;
|
||||||
|
ABSSequentiable temp = list[i];
|
||||||
|
while (j > 0 && list[j - 1].sequencedPosition > temp.sequencedPosition) {
|
||||||
|
list[j] = list[j - 1];
|
||||||
|
j = j - 1;
|
||||||
|
}
|
||||||
|
list[j] = temp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// // Quicker but doesn't implement stable sort
|
||||||
|
// static int SortSequencedObjs(ABSSequentiable a, ABSSequentiable b)
|
||||||
|
// {
|
||||||
|
// if (a.sequencedPosition > b.sequencedPosition) return 1;
|
||||||
|
// if (a.sequencedPosition < b.sequencedPosition) return -1;
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user