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

If time is 0, now tween's won't be updated at all (unless they're timeScale independent)

This commit is contained in:
Demigiant 2017-07-12 17:11:44 +02:00
parent 3347210ee0
commit 186d408de0
48 changed files with 48 additions and 28 deletions

View File

@ -6,28 +6,38 @@ using UnityEngine.SceneManagement;
public class TempPro : MonoBehaviour
{
public DOTweenPath target;
public Transform target;
public Vector3 damageShakeStrength = new Vector3( 0.4f, 0.2f, 0 );
public int damageShakeVibration = 7;
public float damageShakeRandomness = 15;
public float damageShakeDuration = 1.5f;
private Tweener screenShake;
IEnumerator Start()
{
Tween t = this.transform.DOMoveX(2, 2).OnRewind(()=> Debug.Log("Rewind 0"));
yield return new WaitForSeconds(1);
t.Rewind();
// target.GetTween().Rewind();
}
private Vector3 original;
// Use this for initialization
void Start()
{
original = target.position;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space)) SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
if ( Input.GetKeyDown( KeyCode.K ) )
Time.timeScale = Time.timeScale < 1 ? Time.timeScale = 1 : 0;
public void OnComplete()
{
Debug.Log("COMPLETE");
}
public void OnRewind()
{
Debug.Log("REWIND");
if ( Input.GetKeyDown( KeyCode.S ) )
{
Vector3 shakeOffset = new Vector3();
screenShake = DOTween.Shake( () => shakeOffset, x => { shakeOffset = x; target.position += x; }, damageShakeDuration, damageShakeStrength, damageShakeVibration, damageShakeRandomness, false )
.SetUpdate( false );
// screenShake = target.DOMoveX(10, damageShakeDuration);
// screenShake = target.DOShakePosition(damageShakeDuration, damageShakeStrength, damageShakeVibration, damageShakeRandomness, false);
screenShake.OnComplete( () =>
{
screenShake = target.DOMove( original, 0.5f ).OnComplete( () => screenShake = null ).SetUpdate( false );
} );
}
}
}

View File

@ -6,20 +6,29 @@ using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using UnityEngine;
using UnityEngine.UI;
public class TempTests : BrainBase
{
public RectTransform target;
public Transform target;
Sequence seq;
void Start()
private void Awake()
{
DOTween.Init();
}
// DOTween.Init();
//
// seq = DOTween.Sequence()
// .OnComplete(()=> Debug.Log("COMPLETE"));
// seq.AppendInterval(1);
// seq.Append(target.DOMoveX(5, 1).OnComplete(()=> Debug.Log("Tween 0 complete")));
// seq.AppendCallback(() => {
// Debug.Log("Callback fired");
// target.DOMoveX(-5, 1);
// });
public void Shake(float duration)
{
target.DOShakeScale(duration, 0.15f, 10, 90f, true)
.SetEase(Ease.InOutBack)
.Play();
seq = DOTween.Sequence();
seq.AppendInterval(2)
.Append(target.DOMoveX(100, 1))
.AppendCallback(() => { target.DOMoveX(-50, 2); });
}
}

View File

@ -351,6 +351,7 @@ namespace DG.Tweening.Core
if (!t.isPlaying) continue;
t.creationLocked = true; // Lock tween creation methods from now on
float tDeltaTime = (t.isIndependentUpdate ? independentTime : deltaTime) * t.timeScale;
if (tDeltaTime <= 0) continue; // Skip update in case time is 0
if (!t.delayComplete) {
tDeltaTime = t.UpdateDelay(t.elapsedDelay + tDeltaTime);
if (tDeltaTime <= -1) {

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.