1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-21 01:36:05 +08:00

ChangeStart/End/Values now works correctly inside OnUpdate callbacks

This commit is contained in:
Daniele Giardini 2015-05-05 13:29:51 +02:00
parent e4b70b4740
commit dc57c44ab7
15 changed files with 15 additions and 28 deletions

View File

@ -1,34 +1,20 @@
using DG.Tweening;
using DG.Tweening.Core;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Temp : BrainBase
{
public Transform target;
Vector3 orPos;
public Transform target, follow;
void Start()
{
orPos = target.position;
}
void OnGUI()
{
if (GUILayout.Button("Default")) CreateTween();
if (GUILayout.Button("0")) CreateTween(0);
if (GUILayout.Button("1")) CreateTween(1);
if (GUILayout.Button("2")) CreateTween(2);
if (GUILayout.Button("3")) CreateTween(3);
}
void CreateTween(float amplitude = -1)
{
DOTween.KillAll();
target.position = orPos;
if (amplitude > 0) target.DOMoveX(3, 2).SetEase(Ease.OutElastic, amplitude);
else target.DOMoveX(3, 2).SetEase(Ease.OutElastic);
Tweener tween = target.DOMove(follow.position, 2f)
.SetEase(Ease.OutExpo);
tween.OnUpdate(() =>
{
tween.ChangeEndValue(follow.position, true);
});
}
}

View File

@ -9,6 +9,7 @@ namespace DG.Tweening.Core.Enums
internal enum UpdateMode
{
Update,
Goto // Treats update as a full goto, thus not calling eventual onStepComplete callbacks
Goto, // Treats update as a full goto, thus not calling eventual onStepComplete callbacks
IgnoreOnUpdate // Ignores OnUpdate callback (used when applying some ChangeValue during an OnUpdate call)
}
}

View File

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

View File

@ -234,7 +234,7 @@ namespace DG.Tweening
if (t.ApplyTween(prevPosition, prevCompletedLoops, newCompletedSteps, useInversePosition, updateMode)) return true;
// Additional callbacks
if (t.onUpdate != null) {
if (t.onUpdate != null && updateMode != UpdateMode.IgnoreOnUpdate) {
OnTweenCallback(t.onUpdate);
}
if (t.position <= 0 && t.completedLoops <= 0 && !wasRewinded && t.onRewind != null) {

View File

@ -170,7 +170,7 @@ namespace DG.Tweening
}
// Force rewind
DoGoto(t, 0, 0, UpdateMode.Goto);
DoGoto(t, 0, 0, UpdateMode.IgnoreOnUpdate);
return t;
}
@ -208,7 +208,7 @@ namespace DG.Tweening
}
// Force rewind
DoGoto(t, 0, 0, UpdateMode.Goto);
DoGoto(t, 0, 0, UpdateMode.IgnoreOnUpdate);
return t;
}
@ -235,7 +235,7 @@ namespace DG.Tweening
}
// Force rewind
DoGoto(t, 0, 0, UpdateMode.Goto);
DoGoto(t, 0, 0, UpdateMode.IgnoreOnUpdate);
return t;
}

Binary file not shown.