1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-21 01:36:05 +08:00

Fixed IndexOutOfRangeException when reorganizing tweens and capacity increased the first time without ever having being manually set

This commit is contained in:
Demigiant 2016-04-03 13:58:16 +02:00
parent 08b0f5a677
commit 2a8e7cc55c
50 changed files with 77 additions and 10 deletions

View File

@ -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);
}
}

View File

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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 95e2696918659fc4f941a35a6f007551
timeCreated: 1459677176
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -10,11 +10,17 @@ using UnityEngine.UI;
public class TempTests : BrainBase public class TempTests : BrainBase
{ {
public Color32 color; IEnumerator Start ()
void Start ()
{ {
DOTween.To(()=> color, x=> color = x, Color.red, 2) yield return new WaitForSeconds(0.5f);
.OnUpdate(()=> Debug.Log(color));
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));
} }
} }

View File

@ -1,2 +1,2 @@
m_EditorVersion: 5.4.0b10 m_EditorVersion: 5.3.2f1
m_StandardAssetsVersion: 0 m_StandardAssetsVersion: 0

View File

@ -17,7 +17,7 @@ namespace DG.Tweening.Core
const int _DefaultMaxSequences = 50; 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"; 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 maxTweeners = _DefaultMaxTweeners; // Always >= maxSequences
internal static int maxSequences = _DefaultMaxSequences; // Always <= maxTweeners internal static int maxSequences = _DefaultMaxSequences; // Always <= maxTweeners
internal static bool hasActiveTweens, hasActiveDefaultTweens, hasActiveLateTweens, hasActiveFixedTweens; internal static bool hasActiveTweens, hasActiveDefaultTweens, hasActiveLateTweens, hasActiveFixedTweens;
@ -29,11 +29,11 @@ namespace DG.Tweening.Core
// Tweens contained in Sequences are not inside the active lists // 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) // 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 Tween[] _pooledTweeners = new Tween[_DefaultMaxTweeners];
static readonly Stack<Tween> _PooledSequences = new Stack<Tween>(); 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 int _maxActiveLookupId = -1; // Highest full ID in _activeTweens
static bool _requiresActiveReorganization; // True when _activeTweens need to be reorganized to fill empty spaces 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 static int _reorganizeFromId = -1; // First null ID from which to reorganize

View File

@ -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.1.200"; public static readonly string Version = "1.1.250";
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Options //////////////////////////////////// // Options ////////////////////////////////////

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.