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

Fixed rare floating point imprecision when Sequences calculate nested tweens goto

This commit is contained in:
Daniele Giardini 2015-04-28 14:45:49 +02:00
parent 1242c008c4
commit 520de672f3
13 changed files with 22 additions and 21 deletions

View File

@ -1,29 +1,28 @@
using UnityEngine;
using System.Collections;
using DG.Tweening;
using DG.Tweening.Core;
public class NestedSequencesCallbacks : BrainBase
{
public Transform target;
int count;
public float[] durations = new[] {
0.2f, 0.2f, 5.16f, 3f, 0.4f
};
void Start()
{
int loops = 10;
DOTween.Sequence()
// .Append(DOTween.Sequence()
// .InsertCallback(0.0000001f, ()=> Debug.Log("Nested Sequence callback"))
// // .AppendInterval(0.5f)
// .SetLoops(10)
// )
.Append(
target.DOMoveX(3, 0.0000001f)
.SetLoops(loops)
.OnStepComplete(()=> {
count++;
Debug.Log("Nested Tween callback " + count + "/" + loops);
})
)
.OnComplete(()=> Debug.Log("Sequence complete"));
Sequence timeline = DOTween.Sequence().OnComplete(()=> Debug.Log("timeline complete"));
DOGetter<int> emptyGetter = () => 0;
DOSetter<int> emptySetter = value => {};
int count = durations.Length;
for (int i = 0; i < count; ++i) {
int id = i;
float duration = durations[i];
timeline.Append(
DOTween.To(emptyGetter, emptySetter, 0, duration)
.OnComplete(()=> Debug.Log(string.Format("step {0}/{1} ({2})", id, (count - 1), duration)))
);
}
}
}

View File

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

View File

@ -249,7 +249,8 @@ namespace DG.Tweening
}
} else {
// 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;
Tween t = (Tween)sequentiable;
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 {
// 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;
Tween t = (Tween)sequentiable;
t.isBackwards = false;

Binary file not shown.