mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2026-02-13 10:38:49 +08:00
Fixed rare floating point imprecision when Sequences calculate nested tweens goto
This commit is contained in:
parent
1242c008c4
commit
520de672f3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,29 +1,28 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
|
using DG.Tweening.Core;
|
||||||
|
|
||||||
public class NestedSequencesCallbacks : BrainBase
|
public class NestedSequencesCallbacks : BrainBase
|
||||||
{
|
{
|
||||||
public Transform target;
|
public float[] durations = new[] {
|
||||||
int count;
|
0.2f, 0.2f, 5.16f, 3f, 0.4f
|
||||||
|
};
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
int loops = 10;
|
Sequence timeline = DOTween.Sequence().OnComplete(()=> Debug.Log("timeline complete"));
|
||||||
DOTween.Sequence()
|
DOGetter<int> emptyGetter = () => 0;
|
||||||
// .Append(DOTween.Sequence()
|
DOSetter<int> emptySetter = value => {};
|
||||||
// .InsertCallback(0.0000001f, ()=> Debug.Log("Nested Sequence callback"))
|
|
||||||
// // .AppendInterval(0.5f)
|
int count = durations.Length;
|
||||||
// .SetLoops(10)
|
for (int i = 0; i < count; ++i) {
|
||||||
// )
|
int id = i;
|
||||||
.Append(
|
float duration = durations[i];
|
||||||
target.DOMoveX(3, 0.0000001f)
|
timeline.Append(
|
||||||
.SetLoops(loops)
|
DOTween.To(emptyGetter, emptySetter, 0, duration)
|
||||||
.OnStepComplete(()=> {
|
.OnComplete(()=> Debug.Log(string.Format("step {0}/{1} ({2})", id, (count - 1), duration)))
|
||||||
count++;
|
);
|
||||||
Debug.Log("Nested Tween callback " + count + "/" + loops);
|
}
|
||||||
})
|
|
||||||
)
|
|
||||||
.OnComplete(()=> Debug.Log("Sequence complete"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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.0.630";
|
public static readonly string Version = "1.0.635";
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
// Options ////////////////////////////////////
|
// Options ////////////////////////////////////
|
||||||
|
|||||||
@ -249,7 +249,8 @@ namespace DG.Tweening
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Nested Tweener/Sequence
|
// Nested Tweener/Sequence
|
||||||
float gotoPos = toPos - sequentiable.sequencedPosition;
|
// float gotoPos = toPos - sequentiable.sequencedPosition;
|
||||||
|
float gotoPos = (float)((decimal)toPos - (decimal)sequentiable.sequencedPosition);
|
||||||
if (gotoPos < 0) gotoPos = 0;
|
if (gotoPos < 0) gotoPos = 0;
|
||||||
Tween t = (Tween)sequentiable;
|
Tween t = (Tween)sequentiable;
|
||||||
if (!t.startupDone) continue; // since we're going backwards and this tween never started just ignore it
|
if (!t.startupDone) continue; // since we're going backwards and this tween never started just ignore it
|
||||||
@ -285,7 +286,8 @@ namespace DG.Tweening
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Nested Tweener/Sequence
|
// Nested Tweener/Sequence
|
||||||
float gotoPos = toPos - sequentiable.sequencedPosition;
|
// float gotoPos = toPos - sequentiable.sequencedPosition;
|
||||||
|
float gotoPos = (float)((decimal)toPos - (decimal)sequentiable.sequencedPosition);
|
||||||
if (gotoPos < 0) gotoPos = 0;
|
if (gotoPos < 0) gotoPos = 0;
|
||||||
Tween t = (Tween)sequentiable;
|
Tween t = (Tween)sequentiable;
|
||||||
t.isBackwards = false;
|
t.isBackwards = false;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user