1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2026-02-14 02:58:46 +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 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"));
} }
} }

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

View File

@ -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.