Skip to content

Commit

Permalink
Fixed IndexOutOfRangeException when reorganizing tweens and capacity …
Browse files Browse the repository at this point in the history
…increased the first time without ever having being manually set
  • Loading branch information
Demigiant committed Apr 3, 2016
1 parent 08b0f5a commit 2a8e7cc
Show file tree
Hide file tree
Showing 50 changed files with 77 additions and 10 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll
Binary file not shown.
Binary file modified UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll.mdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll.mdb
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll.mdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified UnityTests.Unity5/Assets/Resources/DOTweenSettings.asset
Binary file not shown.
41 changes: 41 additions & 0 deletions UnityTests.Unity5/Assets/_Tests/Bugs/IndexOutOfRangeReproduced.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using UnityEngine;
using System.Collections;
using DG.Tweening;

public class IndexOutOfRangeReproduced : BrainBase
{
public Transform target;

int totDelayedCalls;
int totCreatedTweens;

void Start()
{
// DOTween.SetTweensCapacity(200, 50);
}

void Update()
{
if (Input.GetKeyDown(KeyCode.Space)) {
for (int j = 0; j < 20; j++) {
totDelayedCalls++;
DOVirtual.DelayedCall(0.1f * j, MakeTween);
}
}
}

void MakeTween()
{
for (int i = 0; i < 50; i++) {
totCreatedTweens++;
Tween t = target.DOMove(new Vector3(1, 1), 0.5f);
if (i == 49) t.OnComplete(()=> DOTween.KillAll());
}
}

void OnGUI()
{
GUILayout.Label("Tweens: " + totCreatedTweens);
GUILayout.Label("Delayed Calls: " + totDelayedCalls);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions UnityTests.Unity5/Assets/_Tests/TempTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@

public class TempTests : BrainBase
{
public Color32 color;

void Start ()
IEnumerator Start ()
{
DOTween.To(()=> color, x=> color = x, Color.red, 2)
.OnUpdate(()=> Debug.Log(color));
yield return new WaitForSeconds(0.5f);

Debug.Log(Time.realtimeSinceStartup);
DOVirtual.DelayedCall(2, ()=> Debug.Log("Call > " + Time.realtimeSinceStartup))
.OnStart(()=> Debug.Log("Start > " + Time.realtimeSinceStartup));

DOTween.Sequence()
.OnStart(()=> Debug.Log("S Start > " + Time.realtimeSinceStartup))
.AppendInterval(2)
.OnComplete(()=> Debug.Log("S Complete > " + Time.realtimeSinceStartup));
}
}
Binary file modified UnityTests.Unity5/ProjectSettings/EditorSettings.asset
Binary file not shown.
2 changes: 1 addition & 1 deletion UnityTests.Unity5/ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 5.4.0b10
m_EditorVersion: 5.3.2f1
m_StandardAssetsVersion: 0
6 changes: 3 additions & 3 deletions _DOTween.Assembly/DOTween/Core/TweenManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal static class TweenManager
const int _DefaultMaxSequences = 50;
const string _MaxTweensReached = "Max Tweens reached: capacity has automatically been increased from #0 to #1. Use DOTween.SetTweensCapacity to set it manually at startup";

internal static int maxActive = _DefaultMaxTweeners; // Always equal to maxTweeners
internal static int maxActive = _DefaultMaxTweeners + _DefaultMaxSequences; // Always equal to maxTweeners + maxSequences
internal static int maxTweeners = _DefaultMaxTweeners; // Always >= maxSequences
internal static int maxSequences = _DefaultMaxSequences; // Always <= maxTweeners
internal static bool hasActiveTweens, hasActiveDefaultTweens, hasActiveLateTweens, hasActiveFixedTweens;
Expand All @@ -29,11 +29,11 @@ internal static class TweenManager

// Tweens contained in Sequences are not inside the active lists
// Arrays are organized (max once per update) so that existing elements are next to each other from 0 to (totActiveTweens - 1)
internal static Tween[] _activeTweens = new Tween[_DefaultMaxTweeners]; // Internal just to allow DOTweenInspector to access it
internal static Tween[] _activeTweens = new Tween[_DefaultMaxTweeners + _DefaultMaxSequences]; // Internal just to allow DOTweenInspector to access it
static Tween[] _pooledTweeners = new Tween[_DefaultMaxTweeners];
static readonly Stack<Tween> _PooledSequences = new Stack<Tween>();

static readonly List<Tween> _KillList = new List<Tween>(_DefaultMaxTweeners);
static readonly List<Tween> _KillList = new List<Tween>(_DefaultMaxTweeners + _DefaultMaxSequences);
static int _maxActiveLookupId = -1; // Highest full ID in _activeTweens
static bool _requiresActiveReorganization; // True when _activeTweens need to be reorganized to fill empty spaces
static int _reorganizeFromId = -1; // First null ID from which to reorganize
Expand Down
2 changes: 1 addition & 1 deletion _DOTween.Assembly/DOTween/DOTween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.1.200";
public static readonly string Version = "1.1.250";

///////////////////////////////////////////////
// Options ////////////////////////////////////
Expand Down
Binary file modified _DOTween.Assembly/bin/DOTween.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween.dll.mdb
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween43.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween43.dll.mdb
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween46.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween46.dll.mdb
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween50.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/DOTween50.dll.mdb
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/Editor/DOTweenEditor.dll
Binary file not shown.
Binary file modified _DOTween.Assembly/bin/Editor/DOTweenEditor.dll.mdb
Binary file not shown.

0 comments on commit 2a8e7cc

Please sign in to comment.