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

[BUGFIX] Implemented Andrey Timofeev fix to IndexOutOfRangeException introduced in Sequences in DOTween 1.2.060

This commit is contained in:
Demigiant 2019-02-23 20:54:42 +01:00
parent 7ec7f52144
commit 1b06f0d7c1
18 changed files with 112 additions and 9 deletions

View File

@ -0,0 +1,72 @@
using DG.Tweening;
using System.Collections;
using UnityEngine;
// Code to replicate by Andrey Timofeev: https://github.com/Demigiant/dotween/pull/288/files#diff-0
public class IndexOutOfRange04 : BrainBase
{
public static int updateCounter = -1;
int _callCounter = 0;
void Start()
{
Time.maximumDeltaTime = 0.02f;
DOTween.Init(true, true, LogBehaviour.Verbose);
DOTween.SetTweensCapacity(1000, 1000);
StartCoroutine(CoTest());
}
IEnumerator CoTest()
{
updateCounter = -1;
yield return null;
yield return null;
yield return null;
updateCounter = 0;
StartSequence(0.75f, true); // callNumber 1
yield return new WaitForSeconds(0.5f);
var t0 = StartSequence(0.75f, false); // callNumber 2
yield return new WaitForSeconds(0.5f);
var t1 = StartSequence(99999f, false); // callNumber 3
StartSequence(99999f, false); // callNumber 4
while (t1.active) yield return null;
// while (t0.active) yield return null;
Debug.Log("Done waiting for tween");
StartSequence(99999f, true); // callNumber 5
}
Tweener StartSequence(float duration, bool failStart)
{
int callNumber = ++_callCounter;
Debug.Log(string.Format("StartSequence, callNumber:{0} duration:{1} failStart:{2}", callNumber, duration, failStart));
GameObject go = new GameObject(callNumber.ToString());
var sequence = DOTween.Sequence();
var tweener = go.transform.DOMoveX(callNumber + 1000, duration);
sequence.Append(tweener);
if (failStart) {
Debug.Log(string.Format("Destroying gameobject, callNumber {0}", callNumber));
Destroy(go);
}
return tweener;
}
void Update()
{
// if (updateCounter >= 0) {
// Debug.Log(string.Format("Update {0}, time: {1}", updateCounter, Time.time));
// ++updateCounter;
// }
}
}

View File

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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f0f1c822430a09140b2a4f0b496a99f4
timeCreated: 1481284574
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -32,7 +32,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.2.180"; // Last version before modules: 1.1.755
public static readonly string Version = "1.2.185"; // Last version before modules: 1.1.755
///////////////////////////////////////////////
// Options ////////////////////////////////////

View File

@ -158,10 +158,9 @@ namespace DG.Tweening
// Returns TRUE in case of success
internal static bool DoStartup(Sequence s)
{
if (s.sequencedTweens.Count == 0 && s._sequencedObjs.Count == 0
&& s.onComplete == null && s.onKill == null && s.onPause == null && s.onPlay == null && s.onRewind == null
&& s.onStart == null && s.onStepComplete == null && s.onUpdate == null
) return false; // Empty Sequence without any callback set
if (s.sequencedTweens.Count == 0 && s._sequencedObjs.Count == 0 && !IsAnyCallbackSet(s)) {
return false; // Empty Sequence without any callback set
}
s.startupDone = true;
s.fullDuration = s.loops > -1 ? s.duration * s.loops : Mathf.Infinity;
@ -268,10 +267,13 @@ namespace DG.Tweening
if (!t.startupDone) continue; // since we're going backwards and this tween never started just ignore it
t.isBackwards = true;
if (TweenManager.Goto(t, gotoPos, false, updateMode)) {
// Nested tween failed. Remove it from Sequence and continue
// (instead of just returning TRUE, which would kill the whole Sequence as before v1.2.060)
// Nested tween failed. If it's the only tween and there's no callbacks mark for killing the whole sequence
// (default behaviour in any case prior to v1.2.060)...
if (s.sequencedTweens.Count == 1 && s._sequencedObjs.Count == 1 && !IsAnyCallbackSet(s)) return true;
// ...otherwise remove failed tween from Sequence and continue
TweenManager.Despawn(t, false);
s._sequencedObjs.RemoveAt(i);
s.sequencedTweens.RemoveAt(i);
--i; --len;
continue;
}
@ -323,10 +325,13 @@ namespace DG.Tweening
//
t.isBackwards = false;
if (TweenManager.Goto(t, gotoPos, false, updateMode)) {
// Nested tween failed. Remove it from Sequence and continue
// (instead of just returning TRUE, which would kill the whole Sequence as before v1.2.060)
// Nested tween failed. If it's the only tween and there's no callbacks mark for killing the whole sequence
// (default behaviour in any case prior to v1.2.060)...
if (s.sequencedTweens.Count == 1 && s._sequencedObjs.Count == 1 && !IsAnyCallbackSet(s)) return true;
// ...otherwise remove failed tween from Sequence and continue
TweenManager.Despawn(t, false);
s._sequencedObjs.RemoveAt(i);
s.sequencedTweens.RemoveAt(i);
--i; --len;
continue;
}
@ -362,6 +367,12 @@ namespace DG.Tweening
}
}
static bool IsAnyCallbackSet(Sequence s)
{
return s.onComplete != null || s.onKill != null || s.onPause != null || s.onPlay != null || s.onRewind != null
|| s.onStart != null || s.onStepComplete != null || s.onUpdate != null;
}
// // Quicker but doesn't implement stable sort
// static int SortSequencedObjs(ABSSequentiable a, ABSSequentiable b)
// {

Binary file not shown.