mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-21 01:36:05 +08:00
[BUGFIX] Implemented Andrey Timofeev fix to IndexOutOfRangeException introduced in Sequences in DOTween 1.2.060
This commit is contained in:
parent
7ec7f52144
commit
1b06f0d7c1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
72
UnityTests.Unity5/Assets/_Tests/Bugs/IndexOutOfRange04.cs
Normal file
72
UnityTests.Unity5/Assets/_Tests/Bugs/IndexOutOfRange04.cs
Normal 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;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ccbd60edbcb37524dac83a3c0381ec1e
|
||||||
|
timeCreated: 1550946250
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
UnityTests.Unity5/Assets/_Tests/Bugs/IndexOutOfRange04.unity
Normal file
BIN
UnityTests.Unity5/Assets/_Tests/Bugs/IndexOutOfRange04.unity
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f0f1c822430a09140b2a4f0b496a99f4
|
||||||
|
timeCreated: 1481284574
|
||||||
|
licenseType: Pro
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -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.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 ////////////////////////////////////
|
// Options ////////////////////////////////////
|
||||||
|
|||||||
@ -158,10 +158,9 @@ namespace DG.Tweening
|
|||||||
// Returns TRUE in case of success
|
// Returns TRUE in case of success
|
||||||
internal static bool DoStartup(Sequence s)
|
internal static bool DoStartup(Sequence s)
|
||||||
{
|
{
|
||||||
if (s.sequencedTweens.Count == 0 && s._sequencedObjs.Count == 0
|
if (s.sequencedTweens.Count == 0 && s._sequencedObjs.Count == 0 && !IsAnyCallbackSet(s)) {
|
||||||
&& s.onComplete == null && s.onKill == null && s.onPause == null && s.onPlay == null && s.onRewind == null
|
return false; // Empty Sequence without any callback set
|
||||||
&& s.onStart == null && s.onStepComplete == null && s.onUpdate == null
|
}
|
||||||
) return false; // Empty Sequence without any callback set
|
|
||||||
|
|
||||||
s.startupDone = true;
|
s.startupDone = true;
|
||||||
s.fullDuration = s.loops > -1 ? s.duration * s.loops : Mathf.Infinity;
|
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
|
if (!t.startupDone) continue; // since we're going backwards and this tween never started just ignore it
|
||||||
t.isBackwards = true;
|
t.isBackwards = true;
|
||||||
if (TweenManager.Goto(t, gotoPos, false, updateMode)) {
|
if (TweenManager.Goto(t, gotoPos, false, updateMode)) {
|
||||||
// Nested tween failed. Remove it from Sequence and continue
|
// Nested tween failed. If it's the only tween and there's no callbacks mark for killing the whole sequence
|
||||||
// (instead of just returning TRUE, which would kill the whole Sequence as before v1.2.060)
|
// (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);
|
TweenManager.Despawn(t, false);
|
||||||
s._sequencedObjs.RemoveAt(i);
|
s._sequencedObjs.RemoveAt(i);
|
||||||
|
s.sequencedTweens.RemoveAt(i);
|
||||||
--i; --len;
|
--i; --len;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -323,10 +325,13 @@ namespace DG.Tweening
|
|||||||
//
|
//
|
||||||
t.isBackwards = false;
|
t.isBackwards = false;
|
||||||
if (TweenManager.Goto(t, gotoPos, false, updateMode)) {
|
if (TweenManager.Goto(t, gotoPos, false, updateMode)) {
|
||||||
// Nested tween failed. Remove it from Sequence and continue
|
// Nested tween failed. If it's the only tween and there's no callbacks mark for killing the whole sequence
|
||||||
// (instead of just returning TRUE, which would kill the whole Sequence as before v1.2.060)
|
// (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);
|
TweenManager.Despawn(t, false);
|
||||||
s._sequencedObjs.RemoveAt(i);
|
s._sequencedObjs.RemoveAt(i);
|
||||||
|
s.sequencedTweens.RemoveAt(i);
|
||||||
--i; --len;
|
--i; --len;
|
||||||
continue;
|
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
|
// // Quicker but doesn't implement stable sort
|
||||||
// static int SortSequencedObjs(ABSSequentiable a, ABSSequentiable b)
|
// static int SortSequencedObjs(ABSSequentiable a, ABSSequentiable b)
|
||||||
// {
|
// {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user