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

- Fixed issues with looping tweens and super-tiny durations

- Allowed DOVirtual.DelayedCall to be set in a loop
This commit is contained in:
Daniele Giardini 2015-03-25 10:32:36 +01:00
parent 7597760e6e
commit ec1756130a
28 changed files with 150 additions and 17 deletions

View File

@ -0,0 +1,29 @@
using UnityEngine;
using System.Collections;
using DG.Tweening;
public class NestedSequencesCallbacks : BrainBase
{
public Transform target;
int count;
void Start()
{
int loops = 10;
DOTween.Sequence()
// .Append(DOTween.Sequence()
// .InsertCallback(0.0000001f, ()=> Debug.Log("Nested Sequence callback"))
// // .AppendInterval(0.5f)
// .SetLoops(10)
// )
.Append(
target.DOMoveX(3, 0.0000001f)
.SetLoops(loops)
.OnStepComplete(()=> {
count++;
Debug.Log("Nested Tween callback " + count + "/" + loops);
})
)
.OnComplete(()=> Debug.Log("Sequence complete"));
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2026035b2228bda46b704e0066c412c8
timeCreated: 1427197908
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 66ec0ed6383df9f4691a2baa8f042412
timeCreated: 1427197899
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -5,11 +5,20 @@ using System.Collections;
public class Temp : BrainBase
{
void Start()
{
Debug.Log("Creating empty sequences");
for (int i = 0; i < 100; ++i) {
DOTween.Sequence();
[SerializeField]
private Vector3 pos;
[SerializeField]
private float duration;
[SerializeField]
private GameObject goToMove;
private Tweener moveTween;
// Update is called once per frame
void Update() {
if(moveTween == null) {
moveTween = goToMove.transform.DOLocalMove(pos, duration).SetAutoKill(false);
}
moveTween.ChangeEndValue(pos, duration, true);
}
}

View File

@ -0,0 +1,17 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
public class EaseCurveSingle : MonoBehaviour
{
public Transform[] targets;
IEnumerator Start()
{
yield return new WaitForSeconds(1);
targets[0].DOMoveX(6, 1.5f).SetEase(Ease.Linear).SetLoops(2, LoopType.Restart);
targets[1].DOMoveX(6, 1.5f).SetEase(Ease.Linear).SetLoops(2, LoopType.Yoyo);
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6f35396bedd659d4fa5a98da4c0785d9
timeCreated: 1427215378
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a15076a6f2a5bbf48b1150b6e1006e4b
timeCreated: 1427215371
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -11,15 +11,16 @@ using System;
public class TempTests : BrainBase
{
public Transform target;
public Vector3[] waypoints;
IEnumerator Start()
{
yield return new WaitForSeconds(0.6f);
Tweener t = target.DOLocalMove(new Vector3(4, 4, 0), 3);
Tween t = target.DOPath(waypoints, 5);
yield return null;
yield return null;
yield return new WaitForSeconds(0.1f);
t.ChangeEndValue(new Vector3(0, 8, 0));
t.GotoWaypoint(2);
}
}

View File

@ -4,13 +4,27 @@ using UnityEngine;
public class VirtualTweens : BrainBase
{
float sampleFloat;
Vector3 vector = Vector3.zero;
float startupTime;
int delayedCalls;
void Start()
IEnumerator Start()
{
DOVirtual.Float(0, 1, 3, UpdateCallback);
yield return new WaitForSeconds(1f);
DOVirtual.DelayedCall(2, ()=> Debug.Log("<color=#00ff00>" + Time.realtimeSinceStartup + " > Wait call complete</color>"));
// DOVirtual.Float(0, 1, 3, UpdateCallback);
// DOVirtual.DelayedCall(2, ()=> Debug.Log("<color=#00ff00>" + Time.realtimeSinceStartup + " > Wait call complete</color>"));
startupTime = Time.realtimeSinceStartup;
DOTween.Sequence()
.Append(DOVirtual.DelayedCall(0.2f, RepeatCallback).SetLoops(10))
.SetEase(Ease.OutQuint);
// DOTween.Sequence()
// .Append(
// DOVirtual.DelayedCall(0.2f, RepeatCallback).SetLoops(10)
// );
}
void UpdateCallback(float val)
@ -19,4 +33,10 @@ public class VirtualTweens : BrainBase
vector.y = DOVirtual.EasedValue(15, 100, val, Ease.OutQuad);
Debug.Log(vector);
}
void RepeatCallback()
{
delayedCalls++;
Debug.Log("<color=#00FF00>" + (Time.realtimeSinceStartup - startupTime) + " > DELAYED CALL " + delayedCalls + "</color>");
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e089f476aa726bd4ead5229bb0fe510b
timeCreated: 1427215444
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ed680544b35cdd649a53e76cb0af15d4
timeCreated: 1427215436
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -534,7 +534,8 @@ namespace DG.Tweening.Core
t.isPlaying = andPlay;
t.delayComplete = true;
t.elapsedDelay = t.delay;
int toCompletedLoops = (int)(to / t.duration);
// int toCompletedLoops = (int)(to / t.duration); // With very small floats creates floating points imprecisions
int toCompletedLoops = Mathf.FloorToInt(to / t.duration); // Takes care of floating points imprecision ((int)Math.Floot doesn't suffice)
float toPosition = to % t.duration;
if (t.loops != -1 && toCompletedLoops >= t.loops) {
toCompletedLoops = t.loops;

View File

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

View File

@ -80,7 +80,7 @@ namespace DG.Tweening
/// <param name="ignoreTimeScale">If TRUE (default) ignores Unity's timeScale</param>
public static Tween DelayedCall(float delay, TweenCallback callback, bool ignoreTimeScale = true)
{
return DOTween.Sequence().AppendInterval(delay).OnComplete(callback).SetUpdate(UpdateType.Normal, ignoreTimeScale).SetAutoKill(true);
return DOTween.Sequence().AppendInterval(delay).OnStepComplete(callback).SetUpdate(UpdateType.Normal, ignoreTimeScale).SetAutoKill(true);
}
#endregion

Binary file not shown.