mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-20 09:16:02 +08:00
Fixed sequence.Complete not completing nested tweens
This commit is contained in:
parent
443a0b1d40
commit
12668ae9cd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
39
UnityTests.Unity5/Assets/_Tests/BlendableTweens.cs
Normal file
39
UnityTests.Unity5/Assets/_Tests/BlendableTweens.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
using DG.Tweening;
|
||||||
|
|
||||||
|
public class BlendableTweens : BrainBase
|
||||||
|
{
|
||||||
|
public Transform[] targets;
|
||||||
|
|
||||||
|
Vector3[] startPositions;
|
||||||
|
|
||||||
|
IEnumerator Start()
|
||||||
|
{
|
||||||
|
startPositions = new Vector3[targets.Length];
|
||||||
|
startPositions[0] = targets[0].position;
|
||||||
|
startPositions[1] = targets[1].position + new Vector3(3, 3, 0);
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(0.6f);
|
||||||
|
|
||||||
|
targets[0].DOBlendableMoveBy(new Vector3(3, 3, 0), 3).SetAutoKill(false).Pause();
|
||||||
|
targets[0].DOBlendableMoveBy(new Vector3(-3, 0, 0), 1f).SetLoops(3, LoopType.Yoyo).SetAutoKill(false).Pause();
|
||||||
|
// Same as above but using From
|
||||||
|
targets[1].DOBlendableMoveBy(new Vector3(3, 3, 0), 3).From().SetAutoKill(false).Pause();
|
||||||
|
targets[1].DOBlendableMoveBy(new Vector3(-3, 0, 0), 1f).SetLoops(3, LoopType.Yoyo).SetAutoKill(false).Pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnGUI()
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("Toggle Pause")) DOTween.TogglePauseAll();
|
||||||
|
if (GUILayout.Button("Restart")) DOTween.RestartAll();
|
||||||
|
if (GUILayout.Button("Flip")) DOTween.FlipAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDrawGizmos()
|
||||||
|
{
|
||||||
|
if (!Application.isPlaying) return;
|
||||||
|
|
||||||
|
foreach (Vector3 pos in startPositions) Gizmos.DrawSphere(pos, 0.2f);
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@ -10,12 +10,13 @@ public class SequenceKillAndComplete : BrainBase
|
|||||||
|
|
||||||
IEnumerator Start()
|
IEnumerator Start()
|
||||||
{
|
{
|
||||||
sequence = DOTween.Sequence();
|
sequence = DOTween.Sequence().OnComplete(()=> Debug.Log("SEQUENCE COMPLETE"));
|
||||||
sequence.Append(target.DOMoveX(3, 3).SetRelative());
|
sequence.Append(target.DOMoveX(3, 3).SetRelative().OnComplete(()=> Debug.Log("Tween A Complete")));
|
||||||
sequence.Join(target.DOMoveY(3, 3).SetRelative());
|
sequence.Join(target.DOMoveY(3, 3).SetRelative().OnComplete(()=> Debug.Log("Tween B Complete")));
|
||||||
|
|
||||||
yield return new WaitForSeconds(1.5f);
|
yield return new WaitForSeconds(1f);
|
||||||
|
|
||||||
|
Debug.Log("<color=#00FF00>COMPLETE</color>");
|
||||||
sequence.Kill(true);
|
sequence.Kill(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,23 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
using System.Collections;
|
|
||||||
using DG.Tweening;
|
|
||||||
|
|
||||||
public class MixedTweens : BrainBase
|
|
||||||
{
|
|
||||||
public Transform target;
|
|
||||||
|
|
||||||
IEnumerator Start()
|
|
||||||
{
|
|
||||||
yield return new WaitForSeconds(0.6f);
|
|
||||||
|
|
||||||
target.DOBlendableMoveBy(new Vector3(3, 3, 0), 3).SetAutoKill(false);
|
|
||||||
target.DOBlendableMoveBy(new Vector3(-3, 0, 0), 1f).SetLoops(3, LoopType.Yoyo).SetAutoKill(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnGUI()
|
|
||||||
{
|
|
||||||
if (GUILayout.Button("Toggle Pause")) DOTween.TogglePauseAll();
|
|
||||||
if (GUILayout.Button("Restart")) DOTween.RestartAll();
|
|
||||||
if (GUILayout.Button("Flip")) DOTween.FlipAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
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.346";
|
public static readonly string Version = "1.0.350";
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
// Options ////////////////////////////////////
|
// Options ////////////////////////////////////
|
||||||
|
|||||||
@ -205,6 +205,8 @@ namespace DG.Tweening
|
|||||||
cyclesDone++;
|
cyclesDone++;
|
||||||
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 (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
|
||||||
if (s.loopType == LoopType.Yoyo && newCompletedSteps % 2 != 0) {
|
if (s.loopType == LoopType.Yoyo && newCompletedSteps % 2 != 0) {
|
||||||
@ -213,8 +215,6 @@ namespace DG.Tweening
|
|||||||
}
|
}
|
||||||
newCompletedSteps = 0;
|
newCompletedSteps = 0;
|
||||||
}
|
}
|
||||||
// If completedLoops or position were changed by some callback, exit here
|
|
||||||
if (expectedCompletedLoops != s.completedLoops || Math.Abs(expectedPosition - s.position) > Single.Epsilon) return !s.active;
|
|
||||||
}
|
}
|
||||||
// Run current cycle
|
// Run current cycle
|
||||||
if (newCompletedSteps == 1 && s.isComplete) return false; // Skip update if complete because multicycle took care of it
|
if (newCompletedSteps == 1 && s.isComplete) return false; // Skip update if complete because multicycle took care of it
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user