1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 09:16:02 +08:00

[bugfix] Fixed issue where playing backwards a tween that was complete caused errors in case the first update timeStep completely rewinded it

This commit is contained in:
Demigiant 2017-01-13 18:02:29 +01:00
parent 8cabb36ec1
commit bcebcb0c8f
50 changed files with 70 additions and 20 deletions

View File

@ -17,7 +17,7 @@ public class IndexOutOfRange02 : BrainBase
foreach (Transform t in targets) t.DOMoveX(10, 10).Play();
yield return new WaitForSeconds(2);
// DOTween.Clear(true);
DOTween.Clear(true);
}
void OnDestroy()

View File

@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class IndexOutOfRange03 : MonoBehaviour
{
public GameObject prefab;
IEnumerator Start()
{
DOTween.Init(true);
for (int i = 0; i < 100; ++i) {
GameObject go = Instantiate(prefab);
go.transform.DOMoveX(2, 4);
}
yield return new WaitForSeconds(2);
Debug.Log("Complete all");
DOTween.CompleteAll();
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5bf4bbdeeee14c44a88191908dbef3fa
timeCreated: 1482833958
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 98991aed6c56e2e4e9b15b4455e150a9
timeCreated: 1481284574
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -13,24 +13,16 @@ public class TempTests : BrainBase
{
public Transform target;
Sequence sequence;
void Start()
IEnumerator Start()
{
sequence = DOTween.Sequence();
sequence.Append(target.DORotate(new Vector3(0,45f,0), 1f).SetEase(Ease.InOutCubic));
sequence.AppendInterval(2f);
sequence.SetLoops(-1, LoopType.Incremental);
sequence.SetRelative(true);
}
Tween t = target.DORotate(new Vector3(0, 0, 90), 0.5f, RotateMode.LocalAxisAdd).SetEase(Ease.Linear)
.SetAutoKill(false).Pause();
t.SetUpdate(true);
t.OnUpdate(()=> Debug.Log("UPDATE " + t.Elapsed() + "/" + t.IsPlaying()));
yield return new WaitForSeconds(0.5f);
public void Pause()
{
sequence.Pause();
}
public void Kil()
{
sequence.Kill();
t.Complete();
// t.Rewind();
t.PlayBackwards();
}
}

View File

@ -385,10 +385,24 @@ namespace DG.Tweening.Core
} else {
if (t.isBackwards) {
toPosition -= tDeltaTime;
while (toPosition < 0 && toCompletedLoops > 0) {
while (toPosition < 0 && toCompletedLoops > -1) {
toPosition += t.duration;
toCompletedLoops--;
}
if (toCompletedLoops < 0 || wasEndPosition && toCompletedLoops < 1) {
// Result is equivalent to a rewind, so set values according to it
toPosition = 0;
toCompletedLoops = wasEndPosition ? 1 : 0;
}
// while (toPosition < 0 && toCompletedLoops > 0) {
// toPosition += t.duration;
// toCompletedLoops--;
// }
// if (wasEndPosition && toCompletedLoops <= 0) {
// // Force-rewind
// Rewind(t, false);
// continue;
// }
} else {
toPosition += tDeltaTime;
while (toPosition >= t.duration && (t.loops == -1 || toCompletedLoops < t.loops)) {

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.