1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2026-02-07 15:54:58 +08:00

Added Debug Mode in DOTween Utility Panel with debugStoreId option

This commit is contained in:
Daniele Giardini 2019-12-12 18:31:19 +01:00
parent 90219d37ba
commit d1cb5fb073
34 changed files with 187 additions and 137 deletions

View File

@ -371,6 +371,13 @@
<summary>If TRUE draws path gizmos in Unity Editor (if the gizmos button is active).
Deactivate this if you want to avoid gizmos overhead while in Unity Editor</summary>
</member>
<member name="F:DG.Tweening.DOTween.debugMode">
<summary>If TRUE activates various debug options</summary>
</member>
<member name="P:DG.Tweening.DOTween.debugStoreTargetId">
<summary>Stores the target id so it can be used to give more info in case of safeMode error capturing.
Only active if both <code>debugMode</code> and <code>useSafeMode</code> are TRUE</summary>
</member>
<member name="F:DG.Tweening.DOTween.defaultUpdateType">
<summary>Default updateType for new tweens.
<para>Default: UpdateType.Normal</para></summary>
@ -2646,6 +2653,11 @@
<member name="P:DG.Tweening.Tween.isRelative">
<summary>Tweeners-only (ignored by Sequences), returns TRUE if the tween was set as relative</summary>
</member>
<member name="F:DG.Tweening.Tween.debugTargetId">
<summary>
Set by SetTarget if DOTween's Debug Mode is on (see DOTween Utility Panel -> "Store GameObject's ID" debug option
</summary>
</member>
<member name="P:DG.Tweening.Tween.active">
<summary>FALSE when tween is (or should be) despawned - set only by TweenManager</summary>
</member>

View File

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
public class DebugMode : BrainBase
{
public Transform target;
IEnumerator Start()
{
yield return new WaitForSeconds(0.5f);
Debug.Log("Destroy target then try to create tween");
Destroy(target.gameObject);
target.DOMoveX(2, 2);
}
}

View File

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

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2c4e03937802b7745b2f0fb6fd674492
timeCreated: 1576169761
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -11,83 +11,8 @@ using UnityEngine.UI;
public class TempTests : BrainBase
{
private Sequence parent;
private float duration;
// Empty Scene with 3 cubes next to each other named Cube1, Cube2, Cube3.
// Empty game object with script on it. 2 check boxes in inspector to fire the methods.
// Child sequence is a one off. Parent sequence has a restart on complete.
// If you fire parent first, and the boxes do not adhere to the time they just fly away.
// If you fire child first, then fire parent, and the parent sequence uses times.
void Update()
IEnumerator Start()
{
if (Input.GetKeyUp(KeyCode.F5)) {
DOTween.KillAll();
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
if (Input.GetKeyUp(KeyCode.DownArrow))
{
Debug.Log("Create child");
createChild();
}
if (Input.GetKeyUp(KeyCode.UpArrow))
{
Debug.Log("Create parent");
createParent();
}
}
public void createParent()
{
parent = DOTween.Sequence()
.SetAutoKill(false)
.AppendCallback(() => createChild());
Debug.Log("- " + duration);
parent.AppendInterval(duration)
.OnComplete(() => {
Debug.Log("<color=#00ff00>RESTART</color>");
parent.Restart();
});
}
public void createChild()
{
var listy = new List<GameObject>
{
GameObject.Find("Cube1"),
GameObject.Find("Cube2"),
GameObject.Find("Cube3")
};
var child = DOTween.Sequence();
setCallBack(listy, child);
duration = child.Duration();
Debug.Log(">>> duration: " + duration);
}
private void setCallBack(List<GameObject> listy, Sequence child)
{
foreach (var thing in listy)
{
var rand = (float)rando();
Debug.Log("Wait " + thing.name + " " + rand.ToString());
child.AppendCallback(() => planToMove(thing.transform)).AppendInterval(rand); // move each, append a wait interval
}
}
public int rando()
{
var rnd = new System.Random();
return rnd.Next(1, 5);
}
public void planToMove(Transform thing)
{
var rand = rando();
thing.DOMove(new Vector3(thing.position.x, thing.position.y, thing.position.z + rand), .5f); //move the z a random amount beween 1-3.
Debug.Log("Move " + thing.name + " " + rand.ToString());
yield return new WaitForSeconds(1);
}
}

View File

@ -1 +1 @@
m_EditorVersion: 5.6.5f1
m_EditorVersion: 5.6.7f1

View File

@ -32,6 +32,11 @@ namespace DG.Tweening.Core
public bool defaultAutoKill = true;
public LoopType defaultLoopType = LoopType.Restart;
// Debug
public bool debugMode = false;
// Stores the target id so it can be used to give more info in case of safeMode error capturing
public bool debugStoreTargetId = false;
// Pro-only - accessed via DOTweenAnimationInspector
public bool showPreviewPanel = true;

View File

@ -28,9 +28,20 @@ namespace DG.Tweening.Core
if (DOTween.onWillLog != null && !DOTween.onWillLog(LogType.Log, message)) return;
Debug.Log(message);
}
public static void LogWarning(object message)
public static void LogWarning(object message, Tween t = null)
{
message = _LogPrefix + message;
if (DOTween.debugMode && t != null) {
bool hasDebugTargetId = t.debugTargetId != null;
bool hasStringId = t.stringId != null;
bool hasIntId = t.intId != -999;
if (hasDebugTargetId || hasStringId || hasIntId) {
message += "\n";
if (hasDebugTargetId) message += string.Format("-[debug target ID: {0}]-", t.debugTargetId);
if (hasStringId) message += string.Format("-[stringId: {0}]-", t.stringId);
if (hasIntId) message += string.Format("-[intId: {0}]-", t.intId);
}
}
if (DOTween.onWillLog != null && !DOTween.onWillLog(LogType.Warning, message)) return;
Debug.LogWarning(message);
}
@ -67,7 +78,7 @@ namespace DG.Tweening.Core
public static void LogNestedTween(Tween t)
{
LogWarning("This Tween was added to a Sequence and can't be controlled directly");
LogWarning("This Tween was added to a Sequence and can't be controlled directly", t);
}
public static void LogNullTween(Tween t)
@ -77,7 +88,7 @@ namespace DG.Tweening.Core
public static void LogNonPathTween(Tween t)
{
LogWarning("This Tween is not a path tween");
LogWarning("This Tween is not a path tween", t);
}
public static void LogMissingMaterialProperty(string propertyName)
@ -89,14 +100,18 @@ namespace DG.Tweening.Core
LogWarning(string.Format("This material doesn't have a {0} property ID", propertyId));
}
public static void LogRemoveActiveTweenError(string errorInfo)
public static void LogRemoveActiveTweenError(string errorInfo, Tween t)
{
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));
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
), t);
}
public static void LogAddActiveTweenError(string errorInfo)
public static void LogAddActiveTweenError(string errorInfo, Tween t)
{
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));
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
), t);
}
public static void SetLogPriority(LogBehaviour logBehaviour)

View File

@ -229,7 +229,7 @@ namespace DG.Tweening.Core
internal static void Despawn(Tween t, bool modifyActiveLists = true)
{
// Callbacks
if (t.onKill != null) Tween.OnTweenCallback(t.onKill);
if (t.onKill != null) Tween.OnTweenCallback(t.onKill, t);
if (modifyActiveLists) {
// Remove tween from active list
@ -295,7 +295,7 @@ namespace DG.Tweening.Core
Tween t = _activeTweens[i];
if (t != null && t.active) {
t.active = false;
if (t.onKill != null) Tween.OnTweenCallback(t.onKill);
if (t.onKill != null) Tween.OnTweenCallback(t.onKill, t);
}
}
@ -436,7 +436,7 @@ namespace DG.Tweening.Core
// Delay elapsed - call OnPlay if required
if (t.playedOnce && t.onPlay != null) {
// Don't call in case it hasn't started because onStart routine will call it
Tween.OnTweenCallback(t.onPlay);
Tween.OnTweenCallback(t.onPlay, t);
}
}
// Startup (needs to be here other than in Tween.DoGoto in case of speed-based tweens, to calculate duration correctly)
@ -704,7 +704,7 @@ namespace DG.Tweening.Core
} else if (toPosition >= t.duration) toPosition = 0;
// If andPlay is FALSE manage onPause from here because DoGoto won't detect it (since t.isPlaying was already set from here)
bool needsKilling = Tween.DoGoto(t, toPosition, toCompletedLoops, updateMode);
if (!andPlay && wasPlaying && !needsKilling && t.onPause != null) Tween.OnTweenCallback(t.onPause);
if (!andPlay && wasPlaying && !needsKilling && t.onPause != null) Tween.OnTweenCallback(t.onPause, t);
return needsKilling;
}
@ -713,7 +713,7 @@ namespace DG.Tweening.Core
{
if (t.isPlaying) {
t.isPlaying = false;
if (t.onPause != null) Tween.OnTweenCallback(t.onPause);
if (t.onPause != null) Tween.OnTweenCallback(t.onPause, t);
return true;
}
return false;
@ -726,7 +726,7 @@ namespace DG.Tweening.Core
t.isPlaying = true;
if (t.playedOnce && t.delayComplete && t.onPlay != null) {
// Don't call in case there's a delay to run or if it hasn't started because onStart routine will call it
Tween.OnTweenCallback(t.onPlay);
Tween.OnTweenCallback(t.onPlay, t);
}
return true;
}
@ -774,7 +774,7 @@ namespace DG.Tweening.Core
t.isPlaying = true;
if (wasPaused && t.playedOnce && t.delayComplete && t.onPlay != null) {
// Don't call in case there's a delay to run or if it hasn't started because onStart routine will call it
Tween.OnTweenCallback(t.onPlay);
Tween.OnTweenCallback(t.onPlay, t);
}
return true;
}
@ -798,7 +798,7 @@ namespace DG.Tweening.Core
if (t.position > 0 || t.completedLoops > 0 || !t.startupDone) {
rewinded = true;
bool needsKilling = Tween.DoGoto(t, 0, 0, UpdateMode.Goto);
if (!needsKilling && wasPlaying && t.onPause != null) Tween.OnTweenCallback(t.onPause);
if (!needsKilling && wasPlaying && t.onPause != null) Tween.OnTweenCallback(t.onPause, t);
} else {
// Alread rewinded
ManageOnRewindCallbackWhenAlreadyRewinded(t, false);
@ -998,7 +998,7 @@ namespace DG.Tweening.Core
// Safety check (IndexOutOfRangeException)
if (totActiveTweens < 0) {
Debugger.LogAddActiveTweenError("totActiveTweens < 0");
Debugger.LogAddActiveTweenError("totActiveTweens < 0", t);
totActiveTweens = 0;
}
// else if (totActiveTweens > _activeTweens.Length - 1) {
@ -1093,7 +1093,7 @@ namespace DG.Tweening.Core
totActiveDefaultTweens--;
hasActiveDefaultTweens = totActiveDefaultTweens > 0;
} else {
Debugger.LogRemoveActiveTweenError("totActiveDefaultTweens < 0");
Debugger.LogRemoveActiveTweenError("totActiveDefaultTweens < 0", t);
}
} else {
switch (t.updateType) {
@ -1103,7 +1103,7 @@ namespace DG.Tweening.Core
totActiveFixedTweens--;
hasActiveFixedTweens = totActiveFixedTweens > 0;
} else {
Debugger.LogRemoveActiveTweenError("totActiveFixedTweens < 0");
Debugger.LogRemoveActiveTweenError("totActiveFixedTweens < 0", t);
}
break;
case UpdateType.Late:
@ -1112,7 +1112,7 @@ namespace DG.Tweening.Core
totActiveLateTweens--;
hasActiveLateTweens = totActiveLateTweens > 0;
} else {
Debugger.LogRemoveActiveTweenError("totActiveLateTweens < 0");
Debugger.LogRemoveActiveTweenError("totActiveLateTweens < 0", t);
}
break;
default:
@ -1121,7 +1121,7 @@ namespace DG.Tweening.Core
totActiveManualTweens--;
hasActiveManualTweens = totActiveManualTweens > 0;
} else {
Debugger.LogRemoveActiveTweenError("totActiveManualTweens < 0");
Debugger.LogRemoveActiveTweenError("totActiveManualTweens < 0", t);
}
break;
}
@ -1133,17 +1133,17 @@ namespace DG.Tweening.Core
// Safety check (IndexOutOfRangeException)
if (totActiveTweens < 0) {
totActiveTweens = 0;
Debugger.LogRemoveActiveTweenError("totActiveTweens < 0");
Debugger.LogRemoveActiveTweenError("totActiveTweens < 0", t);
}
// Safety check (IndexOutOfRangeException)
if (totActiveTweeners < 0) {
totActiveTweeners = 0;
Debugger.LogRemoveActiveTweenError("totActiveTweeners < 0");
Debugger.LogRemoveActiveTweenError("totActiveTweeners < 0", t);
}
// Safety check (IndexOutOfRangeException)
if (totActiveSequences < 0) {
totActiveSequences = 0;
Debugger.LogRemoveActiveTweenError("totActiveSequences < 0");
Debugger.LogRemoveActiveTweenError("totActiveSequences < 0", t);
}
}

View File

@ -52,7 +52,7 @@ namespace DG.Tweening.Core
public override Tweener ChangeStartValue(object newStartValue, float newDuration = -1)
{
if (isSequenced) {
if (Debugger.logPriority >= 1) Debugger.LogWarning(_TxtCantChangeSequencedValues);
if (Debugger.logPriority >= 1) Debugger.LogWarning(_TxtCantChangeSequencedValues, this);
return this;
}
#if COMPATIBLE
@ -60,7 +60,7 @@ namespace DG.Tweening.Core
#endif
Type valT = newStartValue.GetType();
if (valT != typeofT2) {
if (Debugger.logPriority >= 1) Debugger.LogWarning("ChangeStartValue: incorrect newStartValue type (is " + valT + ", should be " + typeofT2 + ")");
if (Debugger.logPriority >= 1) Debugger.LogWarning("ChangeStartValue: incorrect newStartValue type (is " + valT + ", should be " + typeofT2 + ")", this);
return this;
}
return DoChangeStartValue(this, (T2)newStartValue, newDuration);
@ -73,7 +73,7 @@ namespace DG.Tweening.Core
public override Tweener ChangeEndValue(object newEndValue, float newDuration = -1, bool snapStartValue = false)
{
if (isSequenced) {
if (Debugger.logPriority >= 1) Debugger.LogWarning(_TxtCantChangeSequencedValues);
if (Debugger.logPriority >= 1) Debugger.LogWarning(_TxtCantChangeSequencedValues, this);
return this;
}
#if COMPATIBLE
@ -81,7 +81,7 @@ namespace DG.Tweening.Core
#endif
Type valT = newEndValue.GetType();
if (valT != typeofT2) {
if (Debugger.logPriority >= 1) Debugger.LogWarning("ChangeEndValue: incorrect newEndValue type (is " + valT + ", should be " + typeofT2 + ")");
if (Debugger.logPriority >= 1) Debugger.LogWarning("ChangeEndValue: incorrect newEndValue type (is " + valT + ", should be " + typeofT2 + ")", this);
return this;
}
return DoChangeEndValue(this, (T2)newEndValue, newDuration, snapStartValue);
@ -91,7 +91,7 @@ namespace DG.Tweening.Core
public override Tweener ChangeValues(object newStartValue, object newEndValue, float newDuration = -1)
{
if (isSequenced) {
if (Debugger.logPriority >= 1) Debugger.LogWarning(_TxtCantChangeSequencedValues);
if (Debugger.logPriority >= 1) Debugger.LogWarning(_TxtCantChangeSequencedValues, this);
return this;
}
#if COMPATIBLE
@ -101,11 +101,11 @@ namespace DG.Tweening.Core
Type valT0 = newStartValue.GetType();
Type valT1 = newEndValue.GetType();
if (valT0 != typeofT2) {
if (Debugger.logPriority >= 1) Debugger.LogWarning("ChangeValues: incorrect value type (is " + valT0 + ", should be " + typeofT2 + ")");
if (Debugger.logPriority >= 1) Debugger.LogWarning("ChangeValues: incorrect value type (is " + valT0 + ", should be " + typeofT2 + ")", this);
return this;
}
if (valT1 != typeofT2) {
if (Debugger.logPriority >= 1) Debugger.LogWarning("ChangeValues: incorrect value type (is " + valT1 + ", should be " + typeofT2 + ")");
if (Debugger.logPriority >= 1) Debugger.LogWarning("ChangeValues: incorrect value type (is " + valT1 + ", should be " + typeofT2 + ")", this);
return this;
}
return DoChangeValues(this, (T2)newStartValue, (T2)newEndValue, newDuration);
@ -120,7 +120,7 @@ namespace DG.Tweening.Core
public TweenerCore<T1,T2,TPlugOptions> ChangeStartValue(T2 newStartValue, float newDuration = -1)
{
if (isSequenced) {
if (Debugger.logPriority >= 1) Debugger.LogWarning(_TxtCantChangeSequencedValues);
if (Debugger.logPriority >= 1) Debugger.LogWarning(_TxtCantChangeSequencedValues, this);
return this;
}
return DoChangeStartValue(this, newStartValue, newDuration);
@ -140,7 +140,7 @@ namespace DG.Tweening.Core
public TweenerCore<T1,T2,TPlugOptions> ChangeEndValue(T2 newEndValue, float newDuration = -1, bool snapStartValue = false)
{
if (isSequenced) {
if (Debugger.logPriority >= 1) Debugger.LogWarning(_TxtCantChangeSequencedValues);
if (Debugger.logPriority >= 1) Debugger.LogWarning(_TxtCantChangeSequencedValues, this);
return this;
}
return DoChangeEndValue(this, newEndValue, newDuration, snapStartValue);
@ -154,7 +154,7 @@ namespace DG.Tweening.Core
public TweenerCore<T1,T2,TPlugOptions> ChangeValues(T2 newStartValue, T2 newEndValue, float newDuration = -1)
{
if (isSequenced) {
if (Debugger.logPriority >= 1) Debugger.LogWarning(_TxtCantChangeSequencedValues);
if (Debugger.logPriority >= 1) Debugger.LogWarning(_TxtCantChangeSequencedValues, this);
return this;
}
return DoChangeValues(this, newStartValue, newEndValue, newDuration);

View File

@ -34,7 +34,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.2.305"; // Last version before modules: 1.1.755
public static readonly string Version = "1.2.310"; // Last version before modules: 1.1.755
///////////////////////////////////////////////
// Options ////////////////////////////////////
@ -82,6 +82,16 @@ namespace DG.Tweening
/// <summary>If TRUE draws path gizmos in Unity Editor (if the gizmos button is active).
/// Deactivate this if you want to avoid gizmos overhead while in Unity Editor</summary>
public static bool drawGizmos = true;
// DEBUG OPTIONS
/// <summary>If TRUE activates various debug options</summary>
public static bool debugMode = false;
/// <summary>Stores the target id so it can be used to give more info in case of safeMode error capturing.
/// Only active if both <code>debugMode</code> and <code>useSafeMode</code> are TRUE</summary>
public static bool debugStoreTargetId {
get { return debugMode && useSafeMode && _fooDebugStoreTargetId; }
set { _fooDebugStoreTargetId = value; }
}
static bool _fooDebugStoreTargetId = false;
///////////////////////////////////////////////
// Default options for Tweens /////////////////
@ -195,6 +205,9 @@ namespace DG.Tweening
DOTween.defaultEasePeriod = settings.defaultEasePeriod;
DOTween.defaultAutoKill = settings.defaultAutoKill;
DOTween.defaultLoopType = settings.defaultLoopType;
// Debug options
DOTween.debugMode = settings.debugMode;
DOTween.debugStoreTargetId = settings.debugStoreTargetId;
}
// Log
if (Debugger.logPriority >= 2) Debugger.Log("DOTween initialization (useSafeMode: " + DOTween.useSafeMode + ", recycling: " + (DOTween.defaultRecyclable ? "ON" : "OFF") + ", logBehaviour: " + DOTween.logBehaviour + ")");

View File

@ -146,12 +146,12 @@ namespace DG.Tweening.Plugins
}
if (isBackwards) {
// for (int i = prevWPIndex - 1; i > newWaypointIndex - 1; --i) Tween.OnTweenCallback(t.onWaypointChange, i);
for (int i = prevWPIndex - 1; i > newWaypointIndex - 1; --i) Tween.OnTweenCallback(t.onWaypointChange, i);
for (int i = prevWPIndex - 1; i > newWaypointIndex - 1; --i) Tween.OnTweenCallback(t.onWaypointChange, t, i);
} else {
// for (int i = prevWPIndex + 1; i < newWaypointIndex + 1; ++i) Tween.OnTweenCallback(t.onWaypointChange, i);
for (int i = prevWPIndex + 1; i < newWaypointIndex; ++i) Tween.OnTweenCallback(t.onWaypointChange, i);
for (int i = prevWPIndex + 1; i < newWaypointIndex; ++i) Tween.OnTweenCallback(t.onWaypointChange, t, i);
}
Tween.OnTweenCallback(t.onWaypointChange, newWaypointIndex);
Tween.OnTweenCallback(t.onWaypointChange, t, newWaypointIndex);
}
}
}

View File

@ -258,7 +258,7 @@ namespace DG.Tweening
if (sequentiable.tweenType == TweenType.Callback) {
if (updateMode == UpdateMode.Update && prevPosIsInverse) {
// Debug.Log("<color=#FFEC03>BACKWARDS Callback > " + s.id + " - s.isBackwards: " + s.isBackwards + ", useInverse/prevInverse: " + useInverse + "/" + prevPosIsInverse + " - " + fromPos + " > " + toPos + "</color>");
OnTweenCallback(sequentiable.onStart);
OnTweenCallback(sequentiable.onStart, s);
}
} else {
// Nested Tweener/Sequence
@ -313,7 +313,7 @@ namespace DG.Tweening
// Debug.Log("<color=#FFEC03>FORWARD Callback > " + s.id + " - s.isBackwards: " + s.isBackwards + ", useInverse/prevInverse: " + useInverse + "/" + prevPosIsInverse + " - " + fromPos + " > " + toPos + "</color>");
bool fire = !s.isBackwards && !useInverse && !prevPosIsInverse
|| s.isBackwards && useInverse && !prevPosIsInverse;
if (fire) OnTweenCallback(sequentiable.onStart);
if (fire) OnTweenCallback(sequentiable.onStart, s);
}
} else {
// Nested Tweener/Sequence

View File

@ -78,6 +78,12 @@ namespace DG.Tweening
public float easePeriod; // Public so it can be used with custom plugins
#pragma warning restore 1591
// SPECIAL DEBUG DATA ////////////////////////////////////////////////
/// <summary>
/// Set by SetTarget if DOTween's Debug Mode is on (see DOTween Utility Panel -> "Store GameObject's ID" debug option
/// </summary>
public string debugTargetId;
// SETUP DATA ////////////////////////////////////////////////
internal Type typeofT1; // Only used by Tweeners
@ -125,6 +131,8 @@ namespace DG.Tweening
onStart = onPlay = onRewind = onUpdate = onComplete = onStepComplete = onKill = null;
onWaypointChange = null;
debugTargetId = null;
target = null;
isFrom = false;
isBlendable = false;
@ -197,11 +205,11 @@ namespace DG.Tweening
if (!t.playedOnce && updateMode == UpdateMode.Update) {
t.playedOnce = true;
if (t.onStart != null) {
OnTweenCallback(t.onStart);
OnTweenCallback(t.onStart, t);
if (!t.active) return true; // Tween might have been killed by onStart callback
}
if (t.onPlay != null) {
OnTweenCallback(t.onPlay);
OnTweenCallback(t.onPlay, t);
if (!t.active) return true; // Tween might have been killed by onPlay callback
}
}
@ -253,19 +261,19 @@ namespace DG.Tweening
// Additional callbacks
if (t.onUpdate != null && updateMode != UpdateMode.IgnoreOnUpdate) {
OnTweenCallback(t.onUpdate);
OnTweenCallback(t.onUpdate, t);
}
if (t.position <= 0 && t.completedLoops <= 0 && !wasRewinded && t.onRewind != null) {
OnTweenCallback(t.onRewind);
OnTweenCallback(t.onRewind, t);
}
if (newCompletedSteps > 0 && updateMode == UpdateMode.Update && t.onStepComplete != null) {
for (int i = 0; i < newCompletedSteps; ++i) OnTweenCallback(t.onStepComplete);
for (int i = 0; i < newCompletedSteps; ++i) OnTweenCallback(t.onStepComplete, t);
}
if (t.isComplete && !wasComplete && updateMode != UpdateMode.IgnoreOnComplete && t.onComplete != null) {
OnTweenCallback(t.onComplete);
OnTweenCallback(t.onComplete, t);
}
if (!t.isPlaying && wasPlaying && (!t.isComplete || !t.autoKill) && t.onPause != null) {
OnTweenCallback(t.onPause);
OnTweenCallback(t.onPause, t);
}
// Return
@ -274,7 +282,7 @@ namespace DG.Tweening
// Assumes that the callback exists (because it was previously checked).
// Returns TRUE in case of success, FALSE in case of error (if safeMode is on)
internal static bool OnTweenCallback(TweenCallback callback)
internal static bool OnTweenCallback(TweenCallback callback, Tween t)
{
if (DOTween.useSafeMode) {
try {
@ -283,7 +291,7 @@ namespace DG.Tweening
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
));
), t);
}
DOTween.safeModeReport.Add(SafeModeReport.SafeModeReportType.Callback);
return false; // Callback error
@ -291,7 +299,7 @@ namespace DG.Tweening
} else callback();
return true;
}
internal static bool OnTweenCallback<T>(TweenCallback<T> callback, T param)
internal static bool OnTweenCallback<T>(TweenCallback<T> callback, Tween t, T param)
{
if (DOTween.useSafeMode) {
try {
@ -300,7 +308,7 @@ namespace DG.Tweening
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
));
), t);
}
DOTween.safeModeReport.Add(SafeModeReport.SafeModeReportType.Callback);
return false; // Callback error

View File

@ -574,7 +574,7 @@ namespace DG.Tweening
if (pathTween == null) {
if (Debugger.logPriority > 1) Debugger.LogNonPathTween(t); return Vector3.zero;
} else if (!pathTween.endValue.isFinalized) {
if (Debugger.logPriority > 1) Debugger.LogWarning("The path is not finalized yet"); return Vector3.zero;
if (Debugger.logPriority > 1) Debugger.LogWarning("The path is not finalized yet", t); return Vector3.zero;
}
return pathTween.endValue.GetPoint(pathPercentage, true);
@ -603,7 +603,7 @@ namespace DG.Tweening
if (pathTween == null) {
if (Debugger.logPriority > 1) Debugger.LogNonPathTween(t); return null;
} else if (!pathTween.endValue.isFinalized) {
if (Debugger.logPriority > 1) Debugger.LogWarning("The path is not finalized yet"); return null;
if (Debugger.logPriority > 1) Debugger.LogWarning("The path is not finalized yet", t); return null;
}
return Path.GetDrawPoints(pathTween.endValue, subdivisionsXSegment);
@ -629,7 +629,7 @@ namespace DG.Tweening
if (pathTween == null) {
if (Debugger.logPriority > 1) Debugger.LogNonPathTween(t); return -1;
} else if (!pathTween.endValue.isFinalized) {
if (Debugger.logPriority > 1) Debugger.LogWarning("The path is not finalized yet"); return -1;
if (Debugger.logPriority > 1) Debugger.LogWarning("The path is not finalized yet", t); return -1;
}
return pathTween.endValue.length;

View File

@ -117,6 +117,10 @@ namespace DG.Tweening
{
if (t == null || !t.active) return t;
if (DOTween.debugStoreTargetId) {
Component comp = target as Component;
t.debugTargetId = comp != null ? comp.name : target.ToString();
}
t.target = target;
return t;
}

View File

@ -137,7 +137,7 @@ namespace DG.Tweening
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
));
), t);
}
DOTween.safeModeReport.Add(SafeModeReport.SafeModeReportType.StartupFailure);
return false; // Target/field doesn't exist: kill tween

View File

@ -16,7 +16,7 @@ namespace DG.DOTweenEditor.UI
static void ShowWindow() { Open(); }
const string _Title = "DOTween Utility Panel";
static readonly Vector2 _WinSize = new Vector2(370,600);
static readonly Vector2 _WinSize = new Vector2(370,650);
public const string Id = "DOTweenVersion";
public const string IdPro = "DOTweenProVersion";
static readonly float _HalfBtSize = _WinSize.x * 0.5f - 6;
@ -27,6 +27,7 @@ namespace DG.DOTweenEditor.UI
Vector2 _headerSize, _footerSize;
string _innerTitle;
bool _setupRequired;
Vector2 _scrollVal;
int _selectedTab;
string[] _tabLabels = new[] { "Setup", "Preferences" };
@ -112,6 +113,7 @@ namespace DG.DOTweenEditor.UI
GUILayout.Space(40);
GUILayout.EndHorizontal();
} else {
_scrollVal = GUILayout.BeginScrollView(_scrollVal);
if (_src.modules.showPanel) {
if (DOTweenUtilityWindowModules.Draw(this, _src)) {
_setupRequired = EditorUtils.DOTweenSetupRequired();
@ -134,6 +136,7 @@ namespace DG.DOTweenEditor.UI
break;
}
}
GUILayout.EndScrollView();
}
if (GUI.changed) EditorUtility.SetDirty(_src);
@ -199,14 +202,12 @@ namespace DG.DOTweenEditor.UI
GUI.color = Color.white;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
// GUILayout.BeginVertical(GUI.skin.box);
GUILayout.Label(
"ASMDEFs are useful if you need to reference the extra DOTween modules API (like [<i>UIelement</i>].DOColor)" +
" from other ASMDEFs/Libraries instead of loose scripts," +
" but remember to have those <b>ASMDEFs/Libraries reference DOTween ones</b>.",
EditorGUIUtils.wordWrapRichTextLabelStyle
);
// GUILayout.EndVertical();
GUILayout.Space(3);
GUILayout.BeginHorizontal();
@ -248,6 +249,8 @@ namespace DG.DOTweenEditor.UI
_src.defaultEasePeriod = 0;
_src.defaultAutoKill = true;
_src.defaultLoopType = LoopType.Restart;
_src.debugMode = false;
_src.debugStoreTargetId = false;
EditorUtility.SetDirty(_src);
}
GUILayout.Space(8);
@ -299,6 +302,21 @@ namespace DG.DOTweenEditor.UI
_src.defaultEasePeriod = EditorGUILayout.FloatField("Ease Period", _src.defaultEasePeriod);
_src.defaultAutoKill = EditorGUILayout.Toggle("AutoKill", _src.defaultAutoKill);
_src.defaultLoopType = (LoopType)EditorGUILayout.EnumPopup("Loop Type", _src.defaultLoopType);
GUILayout.Space(8);
_src.debugMode = EditorGUIUtils.ToggleButton(_src.debugMode, new GUIContent("DEBUG MODE", "Turns debug mode options on/off"), true);
if (_src.debugMode) {
GUILayout.BeginVertical(GUI.skin.box);
EditorGUI.BeginDisabledGroup(!_src.useSafeMode && _src.logBehaviour != LogBehaviour.ErrorsOnly);
_src.debugStoreTargetId = EditorGUILayout.Toggle("Store GameObject's ID", _src.debugStoreTargetId);
GUILayout.Label(
"<b>Requires Safe Mode to be active + Default or Verbose LogBehaviour:</b>" +
" when using DO shortcuts stores the relative gameObject's name so it can be returned along the warning logs" +
" (helps with a clearer identification of the warning's target)",
EditorGUIUtils.wordWrapRichTextLabelStyle
);
EditorGUI.EndDisabledGroup();
GUILayout.EndVertical();
}
}
// ===================================================================================

View File

@ -101,10 +101,10 @@ namespace DG.DOTweenEditor.UI
}
// A button which works as a toggle
public static bool ToggleButton(bool toggled, GUIContent content, GUIStyle guiStyle = null, params GUILayoutOption[] options)
public static bool ToggleButton(bool toggled, GUIContent content, bool alert = false, GUIStyle guiStyle = null, params GUILayoutOption[] options)
{
Color orColor = UnityEngine.GUI.backgroundColor;
UnityEngine.GUI.backgroundColor = toggled ? Color.green : Color.white;
UnityEngine.GUI.backgroundColor = toggled ? alert ? Color.red : Color.green : Color.white;
bool clicked = guiStyle == null
? GUILayout.Button(content, options)
: GUILayout.Button(content, guiStyle, options);

View File

@ -371,6 +371,13 @@
<summary>If TRUE draws path gizmos in Unity Editor (if the gizmos button is active).
Deactivate this if you want to avoid gizmos overhead while in Unity Editor</summary>
</member>
<member name="F:DG.Tweening.DOTween.debugMode">
<summary>If TRUE activates various debug options</summary>
</member>
<member name="P:DG.Tweening.DOTween.debugStoreTargetId">
<summary>Stores the target id so it can be used to give more info in case of safeMode error capturing.
Only active if both <code>debugMode</code> and <code>useSafeMode</code> are TRUE</summary>
</member>
<member name="F:DG.Tweening.DOTween.defaultUpdateType">
<summary>Default updateType for new tweens.
<para>Default: UpdateType.Normal</para></summary>
@ -2646,6 +2653,11 @@
<member name="P:DG.Tweening.Tween.isRelative">
<summary>Tweeners-only (ignored by Sequences), returns TRUE if the tween was set as relative</summary>
</member>
<member name="F:DG.Tweening.Tween.debugTargetId">
<summary>
Set by SetTarget if DOTween's Debug Mode is on (see DOTween Utility Panel -> "Store GameObject's ID" debug option
</summary>
</member>
<member name="P:DG.Tweening.Tween.active">
<summary>FALSE when tween is (or should be) despawned - set only by TweenManager</summary>
</member>

Binary file not shown.