1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 17:26:03 +08:00

Fixed bug where Sequences using LoopType.Restart were not firing callbacks at 0 time after the first loop cycle

This commit is contained in:
Daniele Giardini 2015-04-06 11:41:21 +02:00
parent 85229fb5bf
commit 36a47e9c7f
15 changed files with 72 additions and 3 deletions

View File

@ -0,0 +1,47 @@
using UnityEngine;
using System.Collections;
using DG.Tweening;
public class LoopTypeRestart : BrainBase
{
public enum SequenceType
{
Test,
Bugged
}
public SequenceType sequencetype;
public bool initialInterval;
public bool midIntervals = true;
public LoopType loopType = LoopType.Restart;
public Transform target;
IEnumerator Start()
{
yield return new WaitForSeconds(0.6f);
Sequence s = DOTween.Sequence();
s.SetLoops(-1, loopType);
if (sequencetype == SequenceType.Bugged) {
if (initialInterval) s.AppendInterval(0.5f);
s.AppendCallback(()=> {
Debug.Log("Callback A");
MoveSpriteToPoint(new Vector3(0, 0, 0));
});
if (midIntervals) s.AppendInterval(0.5f);
s.AppendCallback(()=> {
Debug.Log("Callback B");
MoveSpriteToPoint(new Vector3(2, 0, 0));
});
if (midIntervals) s.AppendInterval(0.5f);
} else {
s.Append(target.DOMoveX(3, 0.5f));
s.Append(target.DORotate(new Vector3(0, 180, 0), 0.5f));
}
}
void MoveSpriteToPoint(Vector3 destPos)
{
target.DOMove(destPos, 0.5f);
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c653f77de1feeea4ab81f7ba9737d3cc
timeCreated: 1428310452
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b788bdeb5ca734542ba694693885cdfe
timeCreated: 1428310441
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@ -188,8 +188,9 @@ namespace DG.Tweening
if (s.isBackwards) prevPosIsInverse = !prevPosIsInverse;
// Update multiple loop cycles within the same update
if (newCompletedSteps > 0) {
// Debug.Log(Time.frameCount + " <color=#FFEC03>newCompletedSteps = " + newCompletedSteps + "</color> - completedLoops: " + s.completedLoops + " - updateMode: " + updateMode);
// Store expected completedLoops and position, in order to check them after the update cycles.
int expectedCompletedLoops = s.completedLoops + newCompletedSteps;
int expectedCompletedLoops = s.completedLoops;
float expectedPosition = s.position;
//
int cycles = newCompletedSteps;
@ -206,6 +207,7 @@ namespace DG.Tweening
if (s.loopType == LoopType.Yoyo) prevPosIsInverse = !prevPosIsInverse;
}
// If completedLoops or position were changed by some callback, exit here
// Debug.Log(" Internal Cycle Ended > expecteCompletedLoops/completedLoops: " + expectedCompletedLoops + "/" + s.completedLoops + " - expectedPosition/position: " + expectedPosition + "/" + s.position);
if (expectedCompletedLoops != s.completedLoops || Math.Abs(expectedPosition - s.position) > Single.Epsilon) return !s.active;
} else {
// Simply determine correct prevPosition after steps
@ -233,7 +235,7 @@ namespace DG.Tweening
static bool ApplyInternalCycle(Sequence s, float fromPos, float toPos, UpdateMode updateMode, bool useInverse, bool prevPosIsInverse, bool multiCycleStep = false)
{
bool isBackwardsUpdate = toPos < fromPos;
// Debug.Log(Time.frameCount + " " + s.id + " " + (multiCycleStep ? "<color=#FFEC03>Multicycle</color> > " : "Cycle > ") + s.position + "/" + s.duration + " - s.isBackwards: " + s.isBackwards + ", useInverse/prevInverse: " + useInverse + "/" + prevPosIsInverse + " - " + fromPos + " > " + toPos + " - UpdateMode: " + updateMode + ", isPlaying: " + s.isPlaying);
// Debug.Log(Time.frameCount + " " + s.id + " " + (multiCycleStep ? "<color=#FFEC03>Multicycle</color> > " : "Cycle > ") + s.position + "/" + s.duration + " - s.isBackwards: " + s.isBackwards + ", useInverse/prevInverse: " + useInverse + "/" + prevPosIsInverse + " - " + fromPos + " > " + toPos + " - UpdateMode: " + updateMode + ", isPlaying: " + s.isPlaying + ", completedLoops: " + s.completedLoops);
if (isBackwardsUpdate) {
int len = s._sequencedObjs.Count - 1;
for (int i = len; i > -1; --i) {

Binary file not shown.