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:
parent
85229fb5bf
commit
36a47e9c7f
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
47
UnityTests.Unity5/Assets/_Tests/Bugs/LoopTypeRestart.cs
Normal file
47
UnityTests.Unity5/Assets/_Tests/Bugs/LoopTypeRestart.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
UnityTests.Unity5/Assets/_Tests/Bugs/LoopTypeRestart.cs.meta
Normal file
12
UnityTests.Unity5/Assets/_Tests/Bugs/LoopTypeRestart.cs.meta
Normal 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:
|
||||||
BIN
UnityTests.Unity5/Assets/_Tests/Bugs/LoopTypeRestart.unity
Normal file
BIN
UnityTests.Unity5/Assets/_Tests/Bugs/LoopTypeRestart.unity
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b788bdeb5ca734542ba694693885cdfe
|
||||||
|
timeCreated: 1428310441
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@ -21,7 +21,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.435";
|
public static readonly string Version = "1.0.437";
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
// Options ////////////////////////////////////
|
// Options ////////////////////////////////////
|
||||||
|
|||||||
@ -188,8 +188,9 @@ namespace DG.Tweening
|
|||||||
if (s.isBackwards) prevPosIsInverse = !prevPosIsInverse;
|
if (s.isBackwards) prevPosIsInverse = !prevPosIsInverse;
|
||||||
// Update multiple loop cycles within the same update
|
// Update multiple loop cycles within the same update
|
||||||
if (newCompletedSteps > 0) {
|
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.
|
// 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;
|
float expectedPosition = s.position;
|
||||||
//
|
//
|
||||||
int cycles = newCompletedSteps;
|
int cycles = newCompletedSteps;
|
||||||
@ -206,6 +207,7 @@ namespace DG.Tweening
|
|||||||
if (s.loopType == LoopType.Yoyo) prevPosIsInverse = !prevPosIsInverse;
|
if (s.loopType == LoopType.Yoyo) prevPosIsInverse = !prevPosIsInverse;
|
||||||
}
|
}
|
||||||
// If completedLoops or position were changed by some callback, exit here
|
// 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;
|
if (expectedCompletedLoops != s.completedLoops || Math.Abs(expectedPosition - s.position) > Single.Epsilon) return !s.active;
|
||||||
} else {
|
} else {
|
||||||
// Simply determine correct prevPosition after steps
|
// 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)
|
static bool ApplyInternalCycle(Sequence s, float fromPos, float toPos, UpdateMode updateMode, bool useInverse, bool prevPosIsInverse, bool multiCycleStep = false)
|
||||||
{
|
{
|
||||||
bool isBackwardsUpdate = toPos < fromPos;
|
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) {
|
if (isBackwardsUpdate) {
|
||||||
int len = s._sequencedObjs.Count - 1;
|
int len = s._sequencedObjs.Count - 1;
|
||||||
for (int i = len; i > -1; --i) {
|
for (int i = len; i > -1; --i) {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user