mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-21 01:36:05 +08:00
Added a log in the editor which reports how many errors safe mode prevented, if any
This commit is contained in:
parent
6dc0ac15e5
commit
c8cc8dc6a7
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.
@ -129,6 +129,32 @@ namespace DG.Tweening.Core
|
||||
string s = "Max overall simultaneous active Tweeners/Sequences: " + DOTween.maxActiveTweenersReached + "/" + DOTween.maxActiveSequencesReached;
|
||||
Debugger.LogReport(s);
|
||||
}
|
||||
|
||||
if (DOTween.useSafeMode) {
|
||||
int totSafeModeErrors = DOTween.safeModeReport.GetTotErrors();
|
||||
if (totSafeModeErrors > 0) {
|
||||
string s = string.Format("DOTween's safe mode captured {0} errors." +
|
||||
" This is usually ok (it's what safe mode is there for) but if your game is encountering issues" +
|
||||
" you should set Log Behaviour to Default in DOTween Utility Panel in order to get detailed" +
|
||||
" warnings when an error is captured (consider that these errors are always on the user side).",
|
||||
totSafeModeErrors
|
||||
);
|
||||
if (DOTween.safeModeReport.totMissingTargetOrFieldErrors > 0) {
|
||||
s += "\n- " + DOTween.safeModeReport.totMissingTargetOrFieldErrors + " missing target or field errors";
|
||||
}
|
||||
if (DOTween.safeModeReport.totStartupErrors > 0) {
|
||||
s += "\n- " + DOTween.safeModeReport.totStartupErrors + " startup errors";
|
||||
}
|
||||
if (DOTween.safeModeReport.totCallbackErrors > 0) {
|
||||
s += "\n- " + DOTween.safeModeReport.totCallbackErrors + " errors inside callbacks (these might be important)";
|
||||
}
|
||||
if (DOTween.safeModeReport.totUnsetErrors > 0) {
|
||||
s += "\n- " + DOTween.safeModeReport.totUnsetErrors + " undetermined errors (these might be important)";
|
||||
}
|
||||
Debugger.LogSafeModeReport(s);
|
||||
}
|
||||
}
|
||||
|
||||
// DOTween.initialized = false;
|
||||
// DOTween.instance = null;
|
||||
if (DOTween.instance == this) DOTween.instance = null;
|
||||
|
||||
@ -41,11 +41,18 @@ namespace DG.Tweening.Core
|
||||
|
||||
public static void LogReport(object message)
|
||||
{
|
||||
message = string.Format("<color=#00B500FF>{0} REPORT ► {1}</color>", _LogPrefix, message);
|
||||
message = string.Format("<color=#00B500FF>{0} REPORT ►</color> {1}", _LogPrefix, message);
|
||||
if (DOTween.onWillLog != null && !DOTween.onWillLog(LogType.Log, message)) return;
|
||||
Debug.Log(message);
|
||||
}
|
||||
|
||||
public static void LogSafeModeReport(object message)
|
||||
{
|
||||
message = string.Format("<color=#ff7337>{0} SAFE MODE ►</color> {1}", _LogPrefix, message);
|
||||
if (DOTween.onWillLog != null && !DOTween.onWillLog(LogType.Log, message)) return;
|
||||
Debug.LogWarning(message);
|
||||
}
|
||||
|
||||
public static void LogInvalidTween(Tween t)
|
||||
{
|
||||
LogWarning("This Tween has been killed and is now invalid");
|
||||
|
||||
46
_DOTween.Assembly/DOTween/Core/SafeModeReport.cs
Normal file
46
_DOTween.Assembly/DOTween/Core/SafeModeReport.cs
Normal file
@ -0,0 +1,46 @@
|
||||
// Author: Daniele Giardini - http://www.demigiant.com
|
||||
// Created: 2019/07/24 13:45
|
||||
// License Copyright (c) Daniele Giardini
|
||||
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
||||
|
||||
namespace DG.Tweening.Core
|
||||
{
|
||||
internal struct SafeModeReport
|
||||
{
|
||||
internal enum SafeModeReportType
|
||||
{
|
||||
Unset,
|
||||
TargetOrFieldMissing,
|
||||
Callback,
|
||||
StartupFailure
|
||||
}
|
||||
|
||||
public int totMissingTargetOrFieldErrors { get; private set; }
|
||||
public int totCallbackErrors { get; private set; }
|
||||
public int totStartupErrors { get; private set; }
|
||||
public int totUnsetErrors { get; private set; }
|
||||
|
||||
public void Add(SafeModeReportType type)
|
||||
{
|
||||
switch (type) {
|
||||
case SafeModeReportType.TargetOrFieldMissing:
|
||||
totMissingTargetOrFieldErrors++;
|
||||
break;
|
||||
case SafeModeReportType.Callback:
|
||||
totCallbackErrors++;
|
||||
break;
|
||||
case SafeModeReportType.StartupFailure:
|
||||
totStartupErrors++;
|
||||
break;
|
||||
default:
|
||||
totUnsetErrors++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetTotErrors()
|
||||
{
|
||||
return totMissingTargetOrFieldErrors + totCallbackErrors + totStartupErrors + totUnsetErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -240,6 +240,7 @@ namespace DG.Tweening.Core
|
||||
tweenPlugin.EvaluateAndApply(plugOptions, this, isRelative, getter, setter, updatePosition, startValue, changeValue, duration, useInversePosition, updateNotice);
|
||||
} catch {
|
||||
// Target/field doesn't exist anymore: kill tween
|
||||
DOTween.safeModeReport.Add(SafeModeReport.SafeModeReportType.TargetOrFieldMissing);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -34,7 +34,7 @@ namespace DG.Tweening
|
||||
public class DOTween
|
||||
{
|
||||
/// <summary>DOTween's version</summary>
|
||||
public static readonly string Version = "1.2.260"; // Last version before modules: 1.1.755
|
||||
public static readonly string Version = "1.2.265"; // Last version before modules: 1.1.755
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Options ////////////////////////////////////
|
||||
@ -118,6 +118,7 @@ namespace DG.Tweening
|
||||
public static DOTweenComponent instance;
|
||||
|
||||
internal static int maxActiveTweenersReached, maxActiveSequencesReached; // Controlled by DOTweenInspector if showUnityEditorReport is active
|
||||
internal static SafeModeReport safeModeReport; // Used to store how many safe mode errors are captured in the editor
|
||||
internal static readonly List<TweenCallback> GizmosDelegates = new List<TweenCallback>(); // Can be used by other classes to call internal gizmo draw methods
|
||||
internal static bool initialized; // Can be set to false by DOTweenComponent OnDestroy
|
||||
internal static bool isQuitting; // Set by DOTweenComponent when the application is quitting
|
||||
|
||||
@ -89,6 +89,7 @@
|
||||
<Compile Include="Core\Enums\UpdateMode.cs" />
|
||||
<Compile Include="Core\Extensions.cs" />
|
||||
<Compile Include="Core\DOTweenExternalCommand.cs" />
|
||||
<Compile Include="Core\SafeModeReport.cs" />
|
||||
<Compile Include="Core\SequenceCallback.cs" />
|
||||
<Compile Include="Core\Surrogates\ColorWrapper.cs" />
|
||||
<Compile Include="Core\Surrogates\QuaternionWrapper.cs" />
|
||||
|
||||
@ -285,6 +285,7 @@ namespace DG.Tweening
|
||||
"An error inside a tween callback was silently taken care of ({0}) ► {1}\n\n{2}\n\n", e.TargetSite, e.Message, e.StackTrace
|
||||
));
|
||||
}
|
||||
DOTween.safeModeReport.Add(SafeModeReport.SafeModeReportType.Callback);
|
||||
return false; // Callback error
|
||||
}
|
||||
} else callback();
|
||||
@ -301,6 +302,7 @@ namespace DG.Tweening
|
||||
"An error inside a tween callback was silently taken care of ({0}) ► {1}", e.TargetSite, e.Message
|
||||
));
|
||||
}
|
||||
DOTween.safeModeReport.Add(SafeModeReport.SafeModeReportType.Callback);
|
||||
return false; // Callback error
|
||||
}
|
||||
} else callback(param);
|
||||
|
||||
@ -139,6 +139,7 @@ namespace DG.Tweening
|
||||
"Tween startup failed (NULL target/property - {0}): the tween will now be killed ► {1}", e.TargetSite, e.Message
|
||||
));
|
||||
}
|
||||
DOTween.safeModeReport.Add(SafeModeReport.SafeModeReportType.StartupFailure);
|
||||
return false; // Target/field doesn't exist: kill tween
|
||||
}
|
||||
} else t.startValue = t.tweenPlugin.ConvertToStartValue(t, t.getter());
|
||||
@ -203,6 +204,7 @@ namespace DG.Tweening
|
||||
} catch {
|
||||
// Target/field doesn't exist: kill tween
|
||||
TweenManager.Despawn(t);
|
||||
DOTween.safeModeReport.Add(SafeModeReport.SafeModeReportType.TargetOrFieldMissing);
|
||||
return null;
|
||||
}
|
||||
} else t.startValue = t.tweenPlugin.ConvertToStartValue(t, t.getter());
|
||||
|
||||
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