mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-20 09:16:02 +08:00
Added IndexOutOfRange safety checks, hoping someone one day will be able to reproduce it for me so I can fix it
This commit is contained in:
parent
66a296f34f
commit
3da9f70ce1
@ -2452,7 +2452,7 @@
|
||||
Default is -999 so avoid using an ID like that or it will capture all unset intIds</summary>
|
||||
</member>
|
||||
<member name="F:DG.Tweening.Tween.target">
|
||||
<summary>Tween target (usable for filtering with DOTween static methods). Automatically set by tween creation shorcuts</summary>
|
||||
<summary>Tween target (usable for filtering with DOTween static methods). Automatically set by tween creation shortcuts</summary>
|
||||
</member>
|
||||
<member name="F:DG.Tweening.Tween.onPlay">
|
||||
<summary>Called when the tween is set in a playing state, after any eventual delay.
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b9c6b17aec073847a9d34c432a148ec
|
||||
timeCreated: 1544961652
|
||||
timeCreated: 1548936985
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56bca508bd08a4f44a507f17e7577afb
|
||||
timeCreated: 1544961640
|
||||
timeCreated: 1548936971
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7602d66796c87a4fac3013913374c07
|
||||
timeCreated: 1544961644
|
||||
timeCreated: 1548936979
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3e15b806a8368742ba6f10e794d7b76
|
||||
timeCreated: 1545441841
|
||||
timeCreated: 1549566641
|
||||
licenseType: Pro
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
|
||||
@ -35,7 +35,9 @@ namespace DG.Tweening.Core
|
||||
{
|
||||
if (DOTween.instance == null) DOTween.instance = this;
|
||||
else {
|
||||
Debugger.LogWarning("Duplicate DOTweenComponent instance found in scene: destroying it");
|
||||
if (Debugger.logPriority >= 1) {
|
||||
Debugger.LogWarning("Duplicate DOTweenComponent instance found in scene: destroying it");
|
||||
}
|
||||
Destroy(this.gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -67,9 +67,14 @@ namespace DG.Tweening.Core
|
||||
LogWarning(string.Format("This material doesn't have a {0} property", propertyName));
|
||||
}
|
||||
|
||||
public static void LogRemoveActiveTweenError(string propertyName)
|
||||
public static void LogRemoveActiveTweenError(string errorInfo)
|
||||
{
|
||||
Log(string.Format("Error in RemoveActiveTween.{0}. It's been taken care of so no problems, but Daniele (DOTween's author) is trying to pinpoint it and it would be awesome if you could reproduce this log in a sample project and send it to him. Or even just write him the complete log that was generated by this message. Fixing this would make DOTween slightly faster. Thanks.", propertyName));
|
||||
LogWarning(string.Format("Error in RemoveActiveTween ({0}). It's been taken care of so no problems, but Daniele (DOTween's author) is trying to pinpoint it (it's very rare and he can't reproduce it) so it would be awesome if you could reproduce this log in a sample project and send it to him. Or even just write him the complete log that was generated by this message. Fixing this would make DOTween slightly faster. Thanks.", errorInfo));
|
||||
}
|
||||
|
||||
public static void LogAddActiveTweenError(string errorInfo)
|
||||
{
|
||||
LogWarning(string.Format("Error in AddActiveTween ({0}). It's been taken care of so no problems, but Daniele (DOTween's author) is trying to pinpoint it (it's very rare and he can't reproduce it) so it would be awesome if you could reproduce this log in a sample project and send it to him. Or even just write him the complete log that was generated by this message. Fixing this would make DOTween slightly faster. Thanks.", errorInfo));
|
||||
}
|
||||
|
||||
public static void SetLogPriority(LogBehaviour logBehaviour)
|
||||
|
||||
@ -877,6 +877,16 @@ namespace DG.Tweening.Core
|
||||
{
|
||||
if (_requiresActiveReorganization) ReorganizeActiveTweens();
|
||||
|
||||
// Safety check (IndexOutOfRangeException)
|
||||
if (totActiveTweens < 0) {
|
||||
Debugger.LogAddActiveTweenError("totActiveTweens < 0");
|
||||
totActiveTweens = 0;
|
||||
}
|
||||
// else if (totActiveTweens > _activeTweens.Length - 1) {
|
||||
// Debugger.LogError("AddActiveTween: totActiveTweens > _activeTweens capacity. This should never ever happen. Please report it with instructions on how to reproduce it");
|
||||
// return;
|
||||
// }
|
||||
|
||||
t.active = true;
|
||||
t.updateType = DOTween.defaultUpdateType;
|
||||
t.isIndependentUpdate = DOTween.defaultTimeScaleIndependent;
|
||||
@ -957,36 +967,40 @@ namespace DG.Tweening.Core
|
||||
_activeTweens[index] = null;
|
||||
|
||||
if (t.updateType == UpdateType.Normal) {
|
||||
// Safety check (IndexOutOfRangeException)
|
||||
if (totActiveDefaultTweens > 0) {
|
||||
totActiveDefaultTweens--;
|
||||
hasActiveDefaultTweens = totActiveDefaultTweens > 0;
|
||||
} else {
|
||||
Debugger.LogRemoveActiveTweenError("totActiveDefaultTweens");
|
||||
Debugger.LogRemoveActiveTweenError("totActiveDefaultTweens < 0");
|
||||
}
|
||||
} else {
|
||||
switch (t.updateType) {
|
||||
case UpdateType.Fixed:
|
||||
// Safety check (IndexOutOfRangeException)
|
||||
if (totActiveFixedTweens > 0) {
|
||||
totActiveFixedTweens--;
|
||||
hasActiveFixedTweens = totActiveFixedTweens > 0;
|
||||
} else {
|
||||
Debugger.LogRemoveActiveTweenError("totActiveFixedTweens");
|
||||
Debugger.LogRemoveActiveTweenError("totActiveFixedTweens < 0");
|
||||
}
|
||||
break;
|
||||
case UpdateType.Late:
|
||||
// Safety check (IndexOutOfRangeException)
|
||||
if (totActiveLateTweens > 0) {
|
||||
totActiveLateTweens--;
|
||||
hasActiveLateTweens = totActiveLateTweens > 0;
|
||||
} else {
|
||||
Debugger.LogRemoveActiveTweenError("totActiveLateTweens");
|
||||
Debugger.LogRemoveActiveTweenError("totActiveLateTweens < 0");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Safety check (IndexOutOfRangeException)
|
||||
if (totActiveManualTweens > 0) {
|
||||
totActiveManualTweens--;
|
||||
hasActiveManualTweens = totActiveManualTweens > 0;
|
||||
} else {
|
||||
Debugger.LogRemoveActiveTweenError("totActiveManualTweens");
|
||||
Debugger.LogRemoveActiveTweenError("totActiveManualTweens < 0");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -995,17 +1009,20 @@ namespace DG.Tweening.Core
|
||||
hasActiveTweens = totActiveTweens > 0;
|
||||
if (t.tweenType == TweenType.Tweener) totActiveTweeners--;
|
||||
else totActiveSequences--;
|
||||
// Safety check (IndexOutOfRangeException)
|
||||
if (totActiveTweens < 0) {
|
||||
totActiveTweens = 0;
|
||||
Debugger.LogRemoveActiveTweenError("totActiveTweens");
|
||||
Debugger.LogRemoveActiveTweenError("totActiveTweens < 0");
|
||||
}
|
||||
// Safety check (IndexOutOfRangeException)
|
||||
if (totActiveTweeners < 0) {
|
||||
totActiveTweeners = 0;
|
||||
Debugger.LogRemoveActiveTweenError("totActiveTweeners");
|
||||
Debugger.LogRemoveActiveTweenError("totActiveTweeners < 0");
|
||||
}
|
||||
// Safety check (IndexOutOfRangeException)
|
||||
if (totActiveSequences < 0) {
|
||||
totActiveSequences = 0;
|
||||
Debugger.LogRemoveActiveTweenError("totActiveSequences");
|
||||
Debugger.LogRemoveActiveTweenError("totActiveSequences < 0");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ namespace DG.Tweening
|
||||
public class DOTween
|
||||
{
|
||||
/// <summary>DOTween's version</summary>
|
||||
public static readonly string Version = "1.2.165"; // Last version before modules: 1.1.755
|
||||
public static readonly string Version = "1.2.166"; // Last version before modules: 1.1.755
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Options ////////////////////////////////////
|
||||
|
||||
@ -31,7 +31,7 @@ namespace DG.Tweening
|
||||
/// <summary>Int ID (usable for filtering with DOTween static methods). 4X faster than using an object id, 2X faster than using a string id.
|
||||
/// Default is -999 so avoid using an ID like that or it will capture all unset intIds</summary>
|
||||
public int intId = -999;
|
||||
/// <summary>Tween target (usable for filtering with DOTween static methods). Automatically set by tween creation shorcuts</summary>
|
||||
/// <summary>Tween target (usable for filtering with DOTween static methods). Automatically set by tween creation shortcuts</summary>
|
||||
public object target; // Automatically set by DO shortcuts using SetTarget extension. Also used during Tweener.DoStartup in some special cases
|
||||
// Update type and eventual independence (changed via TweenManager.SetUpdateType)
|
||||
internal UpdateType updateType;
|
||||
@ -280,9 +280,11 @@ namespace DG.Tweening
|
||||
try {
|
||||
callback();
|
||||
} catch (Exception e) {
|
||||
Debugger.LogWarning(string.Format(
|
||||
"An error inside a tween callback was silently taken care of ({0}) ► {1}\n\n{2}\n\n", e.TargetSite, e.Message, e.StackTrace
|
||||
));
|
||||
if (Debugger.logPriority >= 1) {
|
||||
Debugger.LogWarning(string.Format(
|
||||
"An error inside a tween callback was silently taken care of ({0}) ► {1}\n\n{2}\n\n", e.TargetSite, e.Message, e.StackTrace
|
||||
));
|
||||
}
|
||||
return false; // Callback error
|
||||
}
|
||||
} else callback();
|
||||
@ -294,9 +296,11 @@ namespace DG.Tweening
|
||||
try {
|
||||
callback(param);
|
||||
} catch (Exception e) {
|
||||
Debugger.LogWarning(string.Format(
|
||||
"An error inside a tween callback was silently taken care of ({0}) ► {1}", e.TargetSite, e.Message
|
||||
));
|
||||
if (Debugger.logPriority >= 1) {
|
||||
Debugger.LogWarning(string.Format(
|
||||
"An error inside a tween callback was silently taken care of ({0}) ► {1}", e.TargetSite, e.Message
|
||||
));
|
||||
}
|
||||
return false; // Callback error
|
||||
}
|
||||
} else callback(param);
|
||||
|
||||
@ -134,9 +134,11 @@ namespace DG.Tweening
|
||||
try {
|
||||
t.startValue = t.tweenPlugin.ConvertToStartValue(t, t.getter());
|
||||
} catch (Exception e) {
|
||||
Debugger.LogWarning(string.Format(
|
||||
"Tween startup failed (NULL target/property - {0}): the tween will now be killed ► {1}", e.TargetSite, e.Message
|
||||
));
|
||||
if (Debugger.logPriority >= 1) {
|
||||
Debugger.LogWarning(string.Format(
|
||||
"Tween startup failed (NULL target/property - {0}): the tween will now be killed ► {1}", e.TargetSite, e.Message
|
||||
));
|
||||
}
|
||||
return false; // Target/field doesn't exist: kill tween
|
||||
}
|
||||
} else t.startValue = t.tweenPlugin.ConvertToStartValue(t, t.getter());
|
||||
|
||||
@ -2452,7 +2452,7 @@
|
||||
Default is -999 so avoid using an ID like that or it will capture all unset intIds</summary>
|
||||
</member>
|
||||
<member name="F:DG.Tweening.Tween.target">
|
||||
<summary>Tween target (usable for filtering with DOTween static methods). Automatically set by tween creation shorcuts</summary>
|
||||
<summary>Tween target (usable for filtering with DOTween static methods). Automatically set by tween creation shortcuts</summary>
|
||||
</member>
|
||||
<member name="F:DG.Tweening.Tween.onPlay">
|
||||
<summary>Called when the tween is set in a playing state, after any eventual delay.
|
||||
|
||||
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