1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 09:16:02 +08:00

Fix for last nested OnComplete not being called in case of very short Sequences

This commit is contained in:
Demigiant 2015-12-08 11:58:37 +01:00
parent 2f0c080c62
commit c3c28dd915
50 changed files with 61 additions and 9 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 22a87305a04c84e40964cdfae301554e
timeCreated: 1449422216
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
using UnityEngine;
using System.Collections;
using DG.Tweening;
public class SequenceNestedCallbacks : BrainBase
{
public Transform target;
void Start()
{
Sequence sMain = DOTween.Sequence()
.OnComplete(()=> Debug.Log("MAIN > Complete"));
sMain.AppendInterval(0.001f)
.Append(target.DOMoveX(2, 0.0010001f).SetRelative().OnComplete(()=> Debug.Log("S0 > Complete")));
// sMain.Append(target.DOMoveY(2, 1).SetRelative().OnComplete(()=> Debug.Log("S1 > Complete")))
// .Append(target.DOMoveZ(2, 1).SetRelative().OnComplete(()=> Debug.Log("S2 > Complete")))
// .Join(target.DORotate(new Vector3(0, 90, 0), 1).SetRelative().OnComplete(()=> Debug.Log("S3 > Complete")));
}
}

View File

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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1554865e60840d441a085cc476158135
timeCreated: 1449568728
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -9,12 +9,12 @@ using UnityEngine.UI;
public class TempTests : BrainBase
{
public RectTransform rectTrans;
public Transform target;
void Start()
IEnumerator Start()
{
DOTween.Sequence().SetDelay(2)
// .AppendInterval(2)
.Append(rectTrans.DOAnchorPosX(100, 1).SetRelative());
yield return new WaitForSeconds(0.5f);
target.DOMoveY(2, 5).SetRelative().SetEase(Ease.InOutFlash, 8, 1);
}
}

View File

@ -535,11 +535,11 @@ namespace DG.Tweening.Core
}
// Forces the tween to startup and initialize all its data
internal static void ForceInit(Tween t)
internal static void ForceInit(Tween t, bool isSequenced = false)
{
if (t.startupDone) return;
if (!t.Startup()) {
if (!t.Startup() && !isSequenced) {
// Startup failed: kill tween
if (isUpdateLoop) t.active = false; // Just mark it for killing, so the update loop will take care of it
else RemoveActiveTween(t);

View File

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

View File

@ -282,7 +282,6 @@ namespace DG.Tweening
}
}
} else {
// Debug
int len = s._sequencedObjs.Count;
for (int i = 0; i < len; ++i) {
if (!s.active) return true; // Killed by some internal callback
@ -301,6 +300,12 @@ namespace DG.Tweening
// float gotoPos = (float)((decimal)toPos - (decimal)sequentiable.sequencedPosition);
if (gotoPos < 0) gotoPos = 0;
Tween t = (Tween)sequentiable;
// Fix for final nested tween not calling OnComplete in some cases
if (toPos >= sequentiable.sequencedEndPosition) {
if (!t.startupDone) TweenManager.ForceInit(t, true);
if (gotoPos < t.fullDuration) gotoPos = t.fullDuration;
}
//
t.isBackwards = false;
if (TweenManager.Goto(t, gotoPos, false, updateMode)) return true;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.