mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-20 01:06:02 +08:00
[BUGFIX] Fixed TweenManager IndexOutOfRangeException when calling Clear in rare cases
This commit is contained in:
parent
8ec5ab07e6
commit
e6aa8c3b25
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.
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d57d9ae87b3872442b093fedb800fe38
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1571998456
|
||||||
|
licenseType: Pro
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using DG.Tweening;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class IndexOutOfRangeExtended : BrainBase
|
||||||
|
{
|
||||||
|
public Transform[] targets;
|
||||||
|
public Button btReload;
|
||||||
|
|
||||||
|
readonly List<Tween> tweens = new List<Tween>();
|
||||||
|
|
||||||
|
protected override void Awake()
|
||||||
|
{
|
||||||
|
base.Awake();
|
||||||
|
|
||||||
|
btReload.onClick.AddListener(()=> SceneManager.LoadScene(SceneManager.GetActiveScene().name));
|
||||||
|
|
||||||
|
Debug.Log("Create AWAKE tweens");
|
||||||
|
for (int i = 0; i < targets.Length; i++) {
|
||||||
|
Transform t = targets[i];
|
||||||
|
int index = i;
|
||||||
|
tweens.Add(
|
||||||
|
t.DOMoveY(2, 3).SetLoops(-1, LoopType.Yoyo)
|
||||||
|
.OnComplete(() => DOTween.Clear())
|
||||||
|
.OnKill(()=> Debug.Log("Kill AWAKE tween " + index))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
Debug.Log("Create START tweens");
|
||||||
|
for (int i = 0; i < targets.Length; i++) {
|
||||||
|
Transform t = targets[i];
|
||||||
|
int index = i;
|
||||||
|
tweens.Add(
|
||||||
|
t.DOMoveX(2, 3).SetLoops(-1, LoopType.Yoyo)
|
||||||
|
.OnComplete(() => DOTween.Clear())
|
||||||
|
.OnKill(()=> Debug.Log("Kill START tween " + index))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LateUpdate()
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(KeyCode.F5)) SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDisable()
|
||||||
|
{
|
||||||
|
Debug.Log("OnDisable Brain");
|
||||||
|
for (int i = 0; i < tweens.Count; i++) {
|
||||||
|
Tween tween = tweens[i];
|
||||||
|
tween.Kill();
|
||||||
|
Debug.Log("Kill tween from list at index " + i);
|
||||||
|
}
|
||||||
|
tweens.Clear();
|
||||||
|
DOTween.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDestroy()
|
||||||
|
{
|
||||||
|
// foreach (Tween tween in tweens) tween.Kill();
|
||||||
|
// tweens.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ba672ad353205be43b6073352a00bd05
|
||||||
|
timeCreated: 1571998488
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fd4e9a60856ca2346a4e94d67c033be7
|
||||||
|
timeCreated: 1571998475
|
||||||
|
licenseType: Pro
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
// Author: Daniele Giardini - http://www.demigiant.com
|
||||||
|
// Created: 2019/10/25
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using DG.Tweening;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class TweenedObj : MonoBehaviour
|
||||||
|
{
|
||||||
|
Tween t;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
Debug.Log("Create OBJ tween");
|
||||||
|
t = this.transform.DOScale(1.5f, 2).SetLoops(-1, LoopType.Yoyo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDestroy()
|
||||||
|
{
|
||||||
|
Debug.Log("Kill from OnDestroy obj " + this.name);
|
||||||
|
t.Kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDisable()
|
||||||
|
{
|
||||||
|
Debug.Log("DOTween.Clear from OnDisable obj " + this.name);
|
||||||
|
DOTween.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b71ac1dacab745d7979de2305293f992
|
||||||
|
timeCreated: 1571998727
|
||||||
@ -291,9 +291,9 @@ namespace DG.Tweening.Core
|
|||||||
internal static void PurgeAll()
|
internal static void PurgeAll()
|
||||||
{
|
{
|
||||||
// Fire eventual onKill callbacks
|
// Fire eventual onKill callbacks
|
||||||
for (int i = 0; i < totActiveTweens; ++i) {
|
for (int i = 0; i < maxActive; ++i) {
|
||||||
Tween t = _activeTweens[i];
|
Tween t = _activeTweens[i];
|
||||||
if (t != null) {
|
if (t != null && t.active) {
|
||||||
t.active = false;
|
t.active = false;
|
||||||
if (t.onKill != null) Tween.OnTweenCallback(t.onKill);
|
if (t.onKill != null) Tween.OnTweenCallback(t.onKill);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,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.300"; // Last version before modules: 1.1.755
|
public static readonly string Version = "1.2.305"; // Last version before modules: 1.1.755
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
// Options ////////////////////////////////////
|
// Options ////////////////////////////////////
|
||||||
@ -1003,7 +1003,8 @@ namespace DG.Tweening
|
|||||||
{
|
{
|
||||||
InitCheck();
|
InitCheck();
|
||||||
TweenerCore<T1, T2, TPlugOptions> tweener = TweenManager.GetTweener<T1, T2, TPlugOptions>();
|
TweenerCore<T1, T2, TPlugOptions> tweener = TweenManager.GetTweener<T1, T2, TPlugOptions>();
|
||||||
if (!Tweener.Setup(tweener, getter, setter, endValue, duration, plugin)) {
|
bool setupSuccessful = Tweener.Setup(tweener, getter, setter, endValue, duration, plugin);
|
||||||
|
if (!setupSuccessful) {
|
||||||
TweenManager.Despawn(tweener);
|
TweenManager.Despawn(tweener);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
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