1
0
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:
Daniele Giardini 2015-03-26 11:42:16 +01:00
commit 41933d5dda
22 changed files with 59 additions and 44 deletions

View 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);
}
}

View File

@ -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);
} }
} }

View File

@ -5,20 +5,18 @@ using System.Collections;
public class Temp : BrainBase public class Temp : BrainBase
{ {
[SerializeField] public Transform target;
private Vector3 pos;
[SerializeField]
private float duration;
[SerializeField]
private GameObject goToMove;
private Tweener moveTween; IEnumerator Start()
{
yield return new WaitForSeconds(0.6f);
// Update is called once per frame Sequence s0 = DOTween.Sequence().Append(target.DOMoveX(3, 2)).OnComplete(()=> Debug.Log("s0 complete"));
void Update() { Sequence s1 = DOTween.Sequence().Append(target.DOMoveY(3, 2)).OnComplete(()=> Debug.Log("s1 complete"));
if(moveTween == null) { Sequence s = DOTween.Sequence().Append(s0).Append(s1).OnComplete(()=> Debug.Log("MAIN COMPLETE"));
moveTween = goToMove.transform.DOLocalMove(pos, duration).SetAutoKill(false);
} yield return new WaitForSeconds(0.2f);
moveTween.ChangeEndValue(pos, duration, true);
s.Complete();
} }
} }

View File

@ -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();
}
}

View File

@ -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.351";
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Options //////////////////////////////////// // Options ////////////////////////////////////

View File

@ -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

View File

@ -97,7 +97,7 @@ namespace DG.Tweening
if (complete) { if (complete) {
TweenManager.Complete(t); 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) { if (TweenManager.isUpdateLoop) {

Binary file not shown.