mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-21 01:36:05 +08:00
Merge branch 'develop' into blendable_tweens
This commit is contained in:
commit
41933d5dda
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()
|
||||
{
|
||||
sequence = DOTween.Sequence();
|
||||
sequence.Append(target.DOMoveX(3, 3).SetRelative());
|
||||
sequence.Join(target.DOMoveY(3, 3).SetRelative());
|
||||
sequence = DOTween.Sequence().OnComplete(()=> Debug.Log("SEQUENCE COMPLETE"));
|
||||
sequence.Append(target.DOMoveX(3, 3).SetRelative().OnComplete(()=> Debug.Log("Tween A Complete")));
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -5,20 +5,18 @@ using System.Collections;
|
||||
|
||||
public class Temp : BrainBase
|
||||
{
|
||||
[SerializeField]
|
||||
private Vector3 pos;
|
||||
[SerializeField]
|
||||
private float duration;
|
||||
[SerializeField]
|
||||
private GameObject goToMove;
|
||||
public Transform target;
|
||||
|
||||
private Tweener moveTween;
|
||||
IEnumerator Start()
|
||||
{
|
||||
yield return new WaitForSeconds(0.6f);
|
||||
|
||||
// Update is called once per frame
|
||||
void Update() {
|
||||
if(moveTween == null) {
|
||||
moveTween = goToMove.transform.DOLocalMove(pos, duration).SetAutoKill(false);
|
||||
}
|
||||
moveTween.ChangeEndValue(pos, duration, true);
|
||||
Sequence s0 = DOTween.Sequence().Append(target.DOMoveX(3, 2)).OnComplete(()=> Debug.Log("s0 complete"));
|
||||
Sequence s1 = DOTween.Sequence().Append(target.DOMoveY(3, 2)).OnComplete(()=> Debug.Log("s1 complete"));
|
||||
Sequence s = DOTween.Sequence().Append(s0).Append(s1).OnComplete(()=> Debug.Log("MAIN COMPLETE"));
|
||||
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
s.Complete();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@ -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.
Binary file not shown.
@ -21,7 +21,7 @@ namespace DG.Tweening
|
||||
public class DOTween
|
||||
{
|
||||
/// <summary>DOTween's version</summary>
|
||||
public static readonly string Version = "1.0.346";
|
||||
public static readonly string Version = "1.0.351";
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Options ////////////////////////////////////
|
||||
|
||||
@ -205,6 +205,8 @@ namespace DG.Tweening
|
||||
cyclesDone++;
|
||||
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 {
|
||||
// Simply determine correct prevPosition after steps
|
||||
if (s.loopType == LoopType.Yoyo && newCompletedSteps % 2 != 0) {
|
||||
@ -213,8 +215,6 @@ namespace DG.Tweening
|
||||
}
|
||||
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
|
||||
if (newCompletedSteps == 1 && s.isComplete) return false; // Skip update if complete because multicycle took care of it
|
||||
|
||||
@ -97,7 +97,7 @@ namespace DG.Tweening
|
||||
|
||||
if (complete) {
|
||||
TweenManager.Complete(t);
|
||||
if (t.autoKill) return; // Already killed by Complete, so no need to go on
|
||||
if (t.autoKill && t.loops >= 0) return; // Already killed by Complete, so no need to go on
|
||||
}
|
||||
|
||||
if (TweenManager.isUpdateLoop) {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user