1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2026-02-09 08:38:45 +08:00

Added optional "withCallbacks" parameter to Complete/DOComplete

This commit is contained in:
Demigiant 2015-08-04 18:34:29 +02:00
parent 6eeb59473b
commit 13c933a4b8
36 changed files with 143 additions and 41 deletions

View File

@ -523,13 +523,17 @@
Returns a new <see cref="M:DG.Tweening.DOTween.Sequence"/> to be used for tween groups
</summary>
</member>
<member name="M:DG.Tweening.DOTween.CompleteAll">
<member name="M:DG.Tweening.DOTween.CompleteAll(System.Boolean)">
<summary>Completes all tweens and returns the number of actual tweens completed
(meaning tweens that don't have infinite loops and were not already complete)</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.DOTween.Complete(System.Object)">
<member name="M:DG.Tweening.DOTween.Complete(System.Object,System.Boolean)">
<summary>Completes all tweens with the given ID or target and returns the number of actual tweens completed
(meaning the tweens that don't have infinite loops and were not already complete)</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.DOTween.FlipAll">
<summary>Flips all tweens (changing their direction to forward if it was backwards and viceversa),
@ -903,8 +907,10 @@
Methods that extend Tween objects and allow to control or get data from them
</summary>
</member>
<member name="M:DG.Tweening.TweenExtensions.Complete(DG.Tweening.Tween)">
<member name="M:DG.Tweening.TweenExtensions.Complete(DG.Tweening.Tween,System.Boolean)">
<summary>Completes the tween</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.TweenExtensions.Flip(DG.Tweening.Tween)">
<summary>Flips the direction of this tween (backwards if it was going forward or viceversa)</summary>
@ -1620,13 +1626,15 @@
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOComplete(UnityEngine.Component)">
<member name="M:DG.Tweening.ShortcutExtensions.DOComplete(UnityEngine.Component,System.Boolean)">
<summary>
Completes all tweens that have this target as a reference
(meaning tweens that were started from this target, or that had this target added as an Id)
and returns the total number of tweens completed
(meaning the tweens that don't have infinite loops and were not already complete)
</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOKill(UnityEngine.Component,System.Boolean)">
<summary>

View File

@ -17,13 +17,15 @@
<param name="floatName">Name given to the exposed float to set</param>
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions50.DOComplete(UnityEngine.Audio.AudioMixer)">
<member name="M:DG.Tweening.ShortcutExtensions50.DOComplete(UnityEngine.Audio.AudioMixer,System.Boolean)">
<summary>
Completes all tweens that have this target as a reference
(meaning tweens that were started from this target, or that had this target added as an Id)
and returns the total number of tweens completed
(meaning the tweens that don't have infinite loops and were not already complete)
</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions50.DOKill(UnityEngine.Audio.AudioMixer,System.Boolean)">
<summary>

View File

@ -523,13 +523,17 @@
Returns a new <see cref="M:DG.Tweening.DOTween.Sequence"/> to be used for tween groups
</summary>
</member>
<member name="M:DG.Tweening.DOTween.CompleteAll">
<member name="M:DG.Tweening.DOTween.CompleteAll(System.Boolean)">
<summary>Completes all tweens and returns the number of actual tweens completed
(meaning tweens that don't have infinite loops and were not already complete)</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.DOTween.Complete(System.Object)">
<member name="M:DG.Tweening.DOTween.Complete(System.Object,System.Boolean)">
<summary>Completes all tweens with the given ID or target and returns the number of actual tweens completed
(meaning the tweens that don't have infinite loops and were not already complete)</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.DOTween.FlipAll">
<summary>Flips all tweens (changing their direction to forward if it was backwards and viceversa),
@ -903,8 +907,10 @@
Methods that extend Tween objects and allow to control or get data from them
</summary>
</member>
<member name="M:DG.Tweening.TweenExtensions.Complete(DG.Tweening.Tween)">
<member name="M:DG.Tweening.TweenExtensions.Complete(DG.Tweening.Tween,System.Boolean)">
<summary>Completes the tween</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.TweenExtensions.Flip(DG.Tweening.Tween)">
<summary>Flips the direction of this tween (backwards if it was going forward or viceversa)</summary>
@ -1620,13 +1626,15 @@
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOComplete(UnityEngine.Component)">
<member name="M:DG.Tweening.ShortcutExtensions.DOComplete(UnityEngine.Component,System.Boolean)">
<summary>
Completes all tweens that have this target as a reference
(meaning tweens that were started from this target, or that had this target added as an Id)
and returns the total number of tweens completed
(meaning the tweens that don't have infinite loops and were not already complete)
</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOKill(UnityEngine.Component,System.Boolean)">
<summary>

View File

@ -17,13 +17,15 @@
<param name="floatName">Name given to the exposed float to set</param>
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions50.DOComplete(UnityEngine.Audio.AudioMixer)">
<member name="M:DG.Tweening.ShortcutExtensions50.DOComplete(UnityEngine.Audio.AudioMixer,System.Boolean)">
<summary>
Completes all tweens that have this target as a reference
(meaning tweens that were started from this target, or that had this target added as an Id)
and returns the total number of tweens completed
(meaning the tweens that don't have infinite loops and were not already complete)
</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions50.DOKill(UnityEngine.Audio.AudioMixer,System.Boolean)">
<summary>

View File

@ -523,13 +523,17 @@
Returns a new <see cref="M:DG.Tweening.DOTween.Sequence"/> to be used for tween groups
</summary>
</member>
<member name="M:DG.Tweening.DOTween.CompleteAll">
<member name="M:DG.Tweening.DOTween.CompleteAll(System.Boolean)">
<summary>Completes all tweens and returns the number of actual tweens completed
(meaning tweens that don't have infinite loops and were not already complete)</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.DOTween.Complete(System.Object)">
<member name="M:DG.Tweening.DOTween.Complete(System.Object,System.Boolean)">
<summary>Completes all tweens with the given ID or target and returns the number of actual tweens completed
(meaning the tweens that don't have infinite loops and were not already complete)</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.DOTween.FlipAll">
<summary>Flips all tweens (changing their direction to forward if it was backwards and viceversa),
@ -903,8 +907,10 @@
Methods that extend Tween objects and allow to control or get data from them
</summary>
</member>
<member name="M:DG.Tweening.TweenExtensions.Complete(DG.Tweening.Tween)">
<member name="M:DG.Tweening.TweenExtensions.Complete(DG.Tweening.Tween,System.Boolean)">
<summary>Completes the tween</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.TweenExtensions.Flip(DG.Tweening.Tween)">
<summary>Flips the direction of this tween (backwards if it was going forward or viceversa)</summary>
@ -1620,13 +1626,15 @@
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOComplete(UnityEngine.Component)">
<member name="M:DG.Tweening.ShortcutExtensions.DOComplete(UnityEngine.Component,System.Boolean)">
<summary>
Completes all tweens that have this target as a reference
(meaning tweens that were started from this target, or that had this target added as an Id)
and returns the total number of tweens completed
(meaning the tweens that don't have infinite loops and were not already complete)
</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOKill(UnityEngine.Component,System.Boolean)">
<summary>

View File

@ -17,13 +17,15 @@
<param name="floatName">Name given to the exposed float to set</param>
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions50.DOComplete(UnityEngine.Audio.AudioMixer)">
<member name="M:DG.Tweening.ShortcutExtensions50.DOComplete(UnityEngine.Audio.AudioMixer,System.Boolean)">
<summary>
Completes all tweens that have this target as a reference
(meaning tweens that were started from this target, or that had this target added as an Id)
and returns the total number of tweens completed
(meaning the tweens that don't have infinite loops and were not already complete)
</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions50.DOKill(UnityEngine.Audio.AudioMixer,System.Boolean)">
<summary>

View File

@ -0,0 +1,23 @@
using UnityEngine;
using System.Collections;
using DG.Tweening;
public class CompleteWithCallbacks : MonoBehaviour
{
public Transform target;
IEnumerator Start()
{
Sequence s = DOTween.Sequence();
s.AppendCallback(()=> Debug.Log("Start callback"))
.Append(target.DOMoveX(3, 1))
.AppendCallback(()=> Debug.Log("Mid callback"))
.Append(target.DOMoveY(3, 1))
.AppendCallback(()=> Debug.Log("End callback"));
yield return new WaitForSeconds(0.5f);
Debug.Log("WAITED");
s.Complete(true);
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: eda0853a2fbf8574aafcfd9e30d1aa79
timeCreated: 1438704846
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bdca996021e68064fa482c8932e6e105
timeCreated: 1438704840
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -115,7 +115,7 @@ public class Sequences : BrainBase
seqPre.Append(seq);
seqPre.PrependInterval(1);
Sequence mainSeq = DOTween.Sequence().SetUpdate(true).SetLoops(loops, loopType).SetAutoKill(false)
Sequence mainSeq = DOTween.Sequence().SetUpdate(false).SetLoops(loops, loopType).SetAutoKill(false)
.SetId("MAIN SEQUENCE")
.OnStart(()=> DGUtils.Log("MAINSequence Start"))
.OnStepComplete(()=> { stepCompleteMS++; DGUtils.Log("MAINSEQUENCE Step Complete"); })

View File

@ -12,12 +12,19 @@ public class TempTests : BrainBase
public Transform target;
public float delay = 0;
void Start()
IEnumerator Start()
{
DOTween.Sequence()
.Append(target.DOMoveX(2, 2))
.Join(target.DOMoveY(2, 2))
.Append(target.DOScale(2, 2))
.Join(target.DORotate(new Vector3(0, 0, 180), 2));
Vector3[] wps = new[] {
new Vector3(-9.9f, -4.9f, 15.0f), new Vector3(-9.9f, -2.4f, 10.0f), new Vector3(-9.9f, 2.7f, 10.0f), new Vector3(-9.9f, 5.2f, 15.0f)
};
Tween t = target.DOPath(wps, 4).SetEase(Ease.Linear).Pause();
yield return new WaitForSeconds(1);
t.Goto(1);
Debug.Log("1 " + target.position);
yield return new WaitForSeconds(2);
t.Goto(2);
Debug.Log("2 " + target.position);
}
}

View File

@ -437,7 +437,8 @@ namespace DG.Tweening.Core
break;
case OperationType.Complete:
bool hasAutoKill = t.autoKill;
if (Complete(t, false)) {
// If optionalFloat is > 0 completes with callbacks
if (Complete(t, false, optionalFloat > 0 ? UpdateMode.Update : UpdateMode.Goto)) {
// If optionalBool is TRUE only returns tweens killed by completion
totInvolved += !optionalBool ? 1 : hasAutoKill ? 1 : 0;
if (hasAutoKill) {
@ -500,11 +501,11 @@ namespace DG.Tweening.Core
#region Play Operations
internal static bool Complete(Tween t, bool modifyActiveLists = true)
internal static bool Complete(Tween t, bool modifyActiveLists = true, UpdateMode updateMode = UpdateMode.Goto)
{
if (t.loops == -1) return false;
if (!t.isComplete) {
Tween.DoGoto(t, t.duration, t.loops, UpdateMode.Goto);
Tween.DoGoto(t, t.duration, t.loops, updateMode);
t.isPlaying = false;
// Despawn if needed
if (t.autoKill) {

View File

@ -32,7 +32,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.0.805";
public static readonly string Version = "1.0.810";
///////////////////////////////////////////////
// Options ////////////////////////////////////
@ -630,16 +630,20 @@ namespace DG.Tweening
/// <summary>Completes all tweens and returns the number of actual tweens completed
/// (meaning tweens that don't have infinite loops and were not already complete)</summary>
public static int CompleteAll()
/// <param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
/// otherwise they will be ignored</param>
public static int CompleteAll(bool withCallbacks = false)
{
return TweenManager.FilteredOperation(OperationType.Complete, FilterType.All, null, false, 0);
return TweenManager.FilteredOperation(OperationType.Complete, FilterType.All, null, false, withCallbacks ? 1 : 0);
}
/// <summary>Completes all tweens with the given ID or target and returns the number of actual tweens completed
/// (meaning the tweens that don't have infinite loops and were not already complete)</summary>
public static int Complete(object targetOrId)
/// <param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
/// otherwise they will be ignored</param>
public static int Complete(object targetOrId, bool withCallbacks = false)
{
if (targetOrId == null) return 0;
return TweenManager.FilteredOperation(OperationType.Complete, FilterType.TargetOrId, targetOrId, false, 0);
return TweenManager.FilteredOperation(OperationType.Complete, FilterType.TargetOrId, targetOrId, false, withCallbacks ? 1 : 0);
}
// Used internally to complete a tween and return only the number of killed tweens instead than just the completed ones
// (necessary for Kill(complete) operation. Sets optionalBool to TRUE)

View File

@ -1134,9 +1134,11 @@ namespace DG.Tweening
/// and returns the total number of tweens completed
/// (meaning the tweens that don't have infinite loops and were not already complete)
/// </summary>
public static int DOComplete(this Component target)
/// <param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
/// otherwise they will be ignored</param>
public static int DOComplete(this Component target, bool withCallbacks = false)
{
return DOTween.Complete(target);
return DOTween.Complete(target, withCallbacks);
}
/// <summary>

View File

@ -6,6 +6,7 @@
using DG.Tweening.Core;
using DG.Tweening.Core.Easing;
using DG.Tweening.Core.Enums;
using DG.Tweening.Plugins.Core.PathCore;
using DG.Tweening.Plugins.Options;
using UnityEngine;
@ -24,7 +25,9 @@ namespace DG.Tweening
#region Runtime Operations
/// <summary>Completes the tween</summary>
public static void Complete(this Tween t)
/// <param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
/// otherwise they will be ignored</param>
public static void Complete(this Tween t, bool withCallbacks = false)
{
if (t == null) {
if (Debugger.logPriority > 1) Debugger.LogNullTween(t); return;
@ -34,7 +37,7 @@ namespace DG.Tweening
if (Debugger.logPriority > 1) Debugger.LogNestedTween(t); return;
}
TweenManager.Complete(t);
TweenManager.Complete(t, true, withCallbacks ? UpdateMode.Update : UpdateMode.Goto);
}
/// <summary>Flips the direction of this tween (backwards if it was going forward or viceversa)</summary>

View File

@ -38,9 +38,11 @@ namespace DG.Tweening
/// and returns the total number of tweens completed
/// (meaning the tweens that don't have infinite loops and were not already complete)
/// </summary>
public static int DOComplete(this AudioMixer target)
/// <param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
/// otherwise they will be ignored</param>
public static int DOComplete(this AudioMixer target, bool withCallbacks = false)
{
return DOTween.Complete(target);
return DOTween.Complete(target, withCallbacks);
}
/// <summary>

View File

@ -523,13 +523,17 @@
Returns a new <see cref="M:DG.Tweening.DOTween.Sequence"/> to be used for tween groups
</summary>
</member>
<member name="M:DG.Tweening.DOTween.CompleteAll">
<member name="M:DG.Tweening.DOTween.CompleteAll(System.Boolean)">
<summary>Completes all tweens and returns the number of actual tweens completed
(meaning tweens that don't have infinite loops and were not already complete)</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.DOTween.Complete(System.Object)">
<member name="M:DG.Tweening.DOTween.Complete(System.Object,System.Boolean)">
<summary>Completes all tweens with the given ID or target and returns the number of actual tweens completed
(meaning the tweens that don't have infinite loops and were not already complete)</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.DOTween.FlipAll">
<summary>Flips all tweens (changing their direction to forward if it was backwards and viceversa),
@ -903,8 +907,10 @@
Methods that extend Tween objects and allow to control or get data from them
</summary>
</member>
<member name="M:DG.Tweening.TweenExtensions.Complete(DG.Tweening.Tween)">
<member name="M:DG.Tweening.TweenExtensions.Complete(DG.Tweening.Tween,System.Boolean)">
<summary>Completes the tween</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.TweenExtensions.Flip(DG.Tweening.Tween)">
<summary>Flips the direction of this tween (backwards if it was going forward or viceversa)</summary>
@ -1620,13 +1626,15 @@
Also stores the transform as the tween's target so it can be used for filtered operations</summary>
<param name="byValue">The value to tween by</param><param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOComplete(UnityEngine.Component)">
<member name="M:DG.Tweening.ShortcutExtensions.DOComplete(UnityEngine.Component,System.Boolean)">
<summary>
Completes all tweens that have this target as a reference
(meaning tweens that were started from this target, or that had this target added as an Id)
and returns the total number of tweens completed
(meaning the tweens that don't have infinite loops and were not already complete)
</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOKill(UnityEngine.Component,System.Boolean)">
<summary>

Binary file not shown.

Binary file not shown.

View File

@ -17,13 +17,15 @@
<param name="floatName">Name given to the exposed float to set</param>
<param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions50.DOComplete(UnityEngine.Audio.AudioMixer)">
<member name="M:DG.Tweening.ShortcutExtensions50.DOComplete(UnityEngine.Audio.AudioMixer,System.Boolean)">
<summary>
Completes all tweens that have this target as a reference
(meaning tweens that were started from this target, or that had this target added as an Id)
and returns the total number of tweens completed
(meaning the tweens that don't have infinite loops and were not already complete)
</summary>
<param name="withCallbacks">For Sequences only: if TRUE also internal Sequence callbacks will be fired,
otherwise they will be ignored</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions50.DOKill(UnityEngine.Audio.AudioMixer,System.Boolean)">
<summary>