1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-21 09:46:04 +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;
using DG.Tweening.Core;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using System.Collections; using System.Collections;
public class Temp : BrainBase public class Temp : BrainBase
{ {
public Transform target; public Transform target, follow;
Vector3 orPos;
void Start() void Start()
{ {
orPos = target.position; Tweener tween = target.DOMove(follow.position, 2f)
} .SetEase(Ease.OutExpo);
void OnGUI() tween.OnUpdate(() =>
{ {
if (GUILayout.Button("Default")) CreateTween(); tween.ChangeEndValue(follow.position, true);
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);
} }
} }

View File

@ -9,6 +9,7 @@ namespace DG.Tweening.Core.Enums
internal enum UpdateMode internal enum UpdateMode
{ {
Update, 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 public class DOTween
{ {
/// <summary>DOTween's version</summary> /// <summary>DOTween's version</summary>
public static readonly string Version = "1.0.660"; public static readonly string Version = "1.0.665";
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Options //////////////////////////////////// // Options ////////////////////////////////////

View File

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

View File

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

Binary file not shown.