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:
parent
7597760e6e
commit
ec1756130a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2026035b2228bda46b704e0066c412c8
|
||||||
|
timeCreated: 1427197908
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 66ec0ed6383df9f4691a2baa8f042412
|
||||||
|
timeCreated: 1427197899
|
||||||
|
licenseType: Pro
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -5,11 +5,20 @@ using System.Collections;
|
|||||||
|
|
||||||
public class Temp : BrainBase
|
public class Temp : BrainBase
|
||||||
{
|
{
|
||||||
void Start()
|
[SerializeField]
|
||||||
{
|
private Vector3 pos;
|
||||||
Debug.Log("Creating empty sequences");
|
[SerializeField]
|
||||||
for (int i = 0; i < 100; ++i) {
|
private float duration;
|
||||||
DOTween.Sequence();
|
[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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
17
UnityTests.Unity5/Assets/_Tests/EaseCurveSingle.cs
Normal file
17
UnityTests.Unity5/Assets/_Tests/EaseCurveSingle.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
UnityTests.Unity5/Assets/_Tests/EaseCurveSingle.cs.meta
Normal file
12
UnityTests.Unity5/Assets/_Tests/EaseCurveSingle.cs.meta
Normal 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:
|
||||||
BIN
UnityTests.Unity5/Assets/_Tests/EaseCurveSingle.unity
Normal file
BIN
UnityTests.Unity5/Assets/_Tests/EaseCurveSingle.unity
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a15076a6f2a5bbf48b1150b6e1006e4b
|
||||||
|
timeCreated: 1427215371
|
||||||
|
licenseType: Pro
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -11,15 +11,16 @@ using System;
|
|||||||
public class TempTests : BrainBase
|
public class TempTests : BrainBase
|
||||||
{
|
{
|
||||||
public Transform target;
|
public Transform target;
|
||||||
|
public Vector3[] waypoints;
|
||||||
|
|
||||||
IEnumerator Start()
|
IEnumerator Start()
|
||||||
{
|
{
|
||||||
yield return new WaitForSeconds(0.6f);
|
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.GotoWaypoint(2);
|
||||||
|
|
||||||
t.ChangeEndValue(new Vector3(0, 8, 0));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
@ -4,13 +4,27 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class VirtualTweens : BrainBase
|
public class VirtualTweens : BrainBase
|
||||||
{
|
{
|
||||||
|
float sampleFloat;
|
||||||
Vector3 vector = Vector3.zero;
|
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)
|
void UpdateCallback(float val)
|
||||||
@ -19,4 +33,10 @@ public class VirtualTweens : BrainBase
|
|||||||
vector.y = DOVirtual.EasedValue(15, 100, val, Ease.OutQuad);
|
vector.y = DOVirtual.EasedValue(15, 100, val, Ease.OutQuad);
|
||||||
Debug.Log(vector);
|
Debug.Log(vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RepeatCallback()
|
||||||
|
{
|
||||||
|
delayedCalls++;
|
||||||
|
Debug.Log("<color=#00FF00>" + (Time.realtimeSinceStartup - startupTime) + " > DELAYED CALL " + delayedCalls + "</color>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e089f476aa726bd4ead5229bb0fe510b
|
||||||
|
timeCreated: 1427215444
|
||||||
|
licenseType: Pro
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ed680544b35cdd649a53e76cb0af15d4
|
||||||
|
timeCreated: 1427215436
|
||||||
|
licenseType: Pro
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -534,7 +534,8 @@ namespace DG.Tweening.Core
|
|||||||
t.isPlaying = andPlay;
|
t.isPlaying = andPlay;
|
||||||
t.delayComplete = true;
|
t.delayComplete = true;
|
||||||
t.elapsedDelay = t.delay;
|
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;
|
float toPosition = to % t.duration;
|
||||||
if (t.loops != -1 && toCompletedLoops >= t.loops) {
|
if (t.loops != -1 && toCompletedLoops >= t.loops) {
|
||||||
toCompletedLoops = t.loops;
|
toCompletedLoops = t.loops;
|
||||||
|
|||||||
@ -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.340";
|
public static readonly string Version = "1.0.345";
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
// Options ////////////////////////////////////
|
// Options ////////////////////////////////////
|
||||||
|
|||||||
@ -80,7 +80,7 @@ namespace DG.Tweening
|
|||||||
/// <param name="ignoreTimeScale">If TRUE (default) ignores Unity's timeScale</param>
|
/// <param name="ignoreTimeScale">If TRUE (default) ignores Unity's timeScale</param>
|
||||||
public static Tween DelayedCall(float delay, TweenCallback callback, bool ignoreTimeScale = true)
|
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
|
#endregion
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user