1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 09:16:02 +08:00

Added option to choose what happens when a nested tween inside a Sequence fails

This commit is contained in:
Demigiant 2019-02-28 11:19:47 +01:00
parent 8cef4fcbfb
commit 605c5ba9be
21 changed files with 76 additions and 3 deletions

View File

@ -137,6 +137,17 @@
Public so it can be used by external ease factories Public so it can be used by external ease factories
</summary> </summary>
</member> </member>
<member name="T:DG.Tweening.Core.Enums.NestedTweenFailureBehaviour">
<summary>
Behaviour in case a tween nested inside a Sequence fails
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.NestedTweenFailureBehaviour.TryToPreserveSequence">
<summary>If the Sequence contains other elements, kill the failed tween but preserve the rest</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.NestedTweenFailureBehaviour.KillWholeSequence">
<summary>Kill the whole Sequence</summary>
</member>
<member name="T:DG.Tweening.Core.Enums.UpdateNotice"> <member name="T:DG.Tweening.Core.Enums.UpdateNotice">
<summary> <summary>
Additional notices passed to plugins when updating. Additional notices passed to plugins when updating.
@ -290,6 +301,10 @@
(like targets becoming null while a tween is playing). (like targets becoming null while a tween is playing).
<para>Default: TRUE</para></summary> <para>Default: TRUE</para></summary>
</member> </member>
<member name="F:DG.Tweening.DOTween.nestedTweenFailureBehaviour">
<summary>Behaviour in case a tween nested inside a Sequence fails (caught by safe mode).
<para>Default: NestedTweenFailureBehaviour.TryToPreserveSequence</para></summary>
</member>
<member name="F:DG.Tweening.DOTween.showUnityEditorReport"> <member name="F:DG.Tweening.DOTween.showUnityEditorReport">
<summary>If TRUE you will get a DOTween report when exiting play mode (only in the Editor). <summary>If TRUE you will get a DOTween report when exiting play mode (only in the Editor).
Useful to know how many max Tweeners and Sequences you reached and optimize your final project accordingly. Useful to know how many max Tweeners and Sequences you reached and optimize your final project accordingly.

View File

@ -14,6 +14,7 @@ namespace DG.Tweening.Core
public const string AssetFullFilename = AssetName + ".asset"; public const string AssetFullFilename = AssetName + ".asset";
public bool useSafeMode = true; public bool useSafeMode = true;
public SafeModeOptions safeModeOptions = new SafeModeOptions();
public float timeScale = 1; public float timeScale = 1;
public bool useSmoothDeltaTime; public bool useSmoothDeltaTime;
public float maxSmoothUnscaledTime = 0.15f; // Used if useSmoothDeltaTime is TRUE public float maxSmoothUnscaledTime = 0.15f; // Used if useSmoothDeltaTime is TRUE
@ -48,6 +49,12 @@ namespace DG.Tweening.Core
// ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████ // ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ // █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
[Serializable]
public class SafeModeOptions
{
public NestedTweenFailureBehaviour nestedTweenFailureBehaviour = NestedTweenFailureBehaviour.TryToPreserveSequence;
}
[Serializable] [Serializable]
public class ModulesSetup // Editor-only public class ModulesSetup // Editor-only
{ {

View File

@ -0,0 +1,18 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2019/02/28 11:08
// License Copyright (c) Daniele Giardini
// This work is subject to the terms at http://dotween.demigiant.com/license.php
namespace DG.Tweening.Core.Enums
{
/// <summary>
/// Behaviour in case a tween nested inside a Sequence fails
/// </summary>
public enum NestedTweenFailureBehaviour
{
/// <summary>If the Sequence contains other elements, kill the failed tween but preserve the rest</summary>
TryToPreserveSequence,
/// <summary>Kill the whole Sequence</summary>
KillWholeSequence
}
}

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.2.196"; // Last version before modules: 1.1.755 public static readonly string Version = "1.2.200"; // Last version before modules: 1.1.755
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Options //////////////////////////////////// // Options ////////////////////////////////////
@ -41,6 +41,9 @@ namespace DG.Tweening
/// (like targets becoming null while a tween is playing). /// (like targets becoming null while a tween is playing).
/// <para>Default: TRUE</para></summary> /// <para>Default: TRUE</para></summary>
public static bool useSafeMode = true; public static bool useSafeMode = true;
/// <summary>Behaviour in case a tween nested inside a Sequence fails (caught by safe mode).
/// <para>Default: NestedTweenFailureBehaviour.TryToPreserveSequence</para></summary>
public static NestedTweenFailureBehaviour nestedTweenFailureBehaviour = NestedTweenFailureBehaviour.TryToPreserveSequence;
/// <summary>If TRUE you will get a DOTween report when exiting play mode (only in the Editor). /// <summary>If TRUE you will get a DOTween report when exiting play mode (only in the Editor).
/// Useful to know how many max Tweeners and Sequences you reached and optimize your final project accordingly. /// Useful to know how many max Tweeners and Sequences you reached and optimize your final project accordingly.
/// Beware, this will slightly slow down your tweens while inside Unity Editor. /// Beware, this will slightly slow down your tweens while inside Unity Editor.
@ -167,6 +170,7 @@ namespace DG.Tweening
if (useSafeMode == null) DOTween.useSafeMode = settings.useSafeMode; if (useSafeMode == null) DOTween.useSafeMode = settings.useSafeMode;
if (logBehaviour == null) DOTween.logBehaviour = settings.logBehaviour; if (logBehaviour == null) DOTween.logBehaviour = settings.logBehaviour;
if (recycleAllByDefault == null) DOTween.defaultRecyclable = settings.defaultRecyclable; if (recycleAllByDefault == null) DOTween.defaultRecyclable = settings.defaultRecyclable;
DOTween.nestedTweenFailureBehaviour = settings.safeModeOptions.nestedTweenFailureBehaviour;
DOTween.timeScale = settings.timeScale; DOTween.timeScale = settings.timeScale;
DOTween.useSmoothDeltaTime = settings.useSmoothDeltaTime; DOTween.useSmoothDeltaTime = settings.useSmoothDeltaTime;
DOTween.maxSmoothUnscaledTime = settings.maxSmoothUnscaledTime; DOTween.maxSmoothUnscaledTime = settings.maxSmoothUnscaledTime;
@ -220,6 +224,7 @@ namespace DG.Tweening
initialized = false; initialized = false;
useSafeMode = false; useSafeMode = false;
nestedTweenFailureBehaviour = NestedTweenFailureBehaviour.TryToPreserveSequence;
showUnityEditorReport = false; showUnityEditorReport = false;
drawGizmos = true; drawGizmos = true;
timeScale = 1; timeScale = 1;

View File

@ -82,6 +82,7 @@
<Compile Include="Core\Easing\EaseCurve.cs" /> <Compile Include="Core\Easing\EaseCurve.cs" />
<Compile Include="Core\Easing\Flash.cs" /> <Compile Include="Core\Easing\Flash.cs" />
<Compile Include="Core\Enums\FilterType.cs" /> <Compile Include="Core\Enums\FilterType.cs" />
<Compile Include="Core\Enums\NestedTweenFailureBehaviour.cs" />
<Compile Include="Core\Enums\OperationType.cs" /> <Compile Include="Core\Enums\OperationType.cs" />
<Compile Include="Core\Enums\SpecialStartupMode.cs" /> <Compile Include="Core\Enums\SpecialStartupMode.cs" />
<Compile Include="Core\Enums\UpdateNotice.cs" /> <Compile Include="Core\Enums\UpdateNotice.cs" />

View File

@ -269,6 +269,7 @@ namespace DG.Tweening
if (TweenManager.Goto(t, gotoPos, false, updateMode)) { if (TweenManager.Goto(t, gotoPos, false, updateMode)) {
// Nested tween failed. If it's the only tween and there's no callbacks mark for killing the whole sequence // Nested tween failed. If it's the only tween and there's no callbacks mark for killing the whole sequence
// (default behaviour in any case prior to v1.2.060)... // (default behaviour in any case prior to v1.2.060)...
if (DOTween.nestedTweenFailureBehaviour == NestedTweenFailureBehaviour.KillWholeSequence) return true;
if (s.sequencedTweens.Count == 1 && s._sequencedObjs.Count == 1 && !IsAnyCallbackSet(s)) return true; if (s.sequencedTweens.Count == 1 && s._sequencedObjs.Count == 1 && !IsAnyCallbackSet(s)) return true;
// ...otherwise remove failed tween from Sequence and continue // ...otherwise remove failed tween from Sequence and continue
TweenManager.Despawn(t, false); TweenManager.Despawn(t, false);
@ -327,6 +328,7 @@ namespace DG.Tweening
if (TweenManager.Goto(t, gotoPos, false, updateMode)) { if (TweenManager.Goto(t, gotoPos, false, updateMode)) {
// Nested tween failed. If it's the only tween and there's no callbacks mark for killing the whole sequence // Nested tween failed. If it's the only tween and there's no callbacks mark for killing the whole sequence
// (default behaviour in any case prior to v1.2.060)... // (default behaviour in any case prior to v1.2.060)...
if (DOTween.nestedTweenFailureBehaviour == NestedTweenFailureBehaviour.KillWholeSequence) return true;
if (s.sequencedTweens.Count == 1 && s._sequencedObjs.Count == 1 && !IsAnyCallbackSet(s)) return true; if (s.sequencedTweens.Count == 1 && s._sequencedObjs.Count == 1 && !IsAnyCallbackSet(s)) return true;
// ...otherwise remove failed tween from Sequence and continue // ...otherwise remove failed tween from Sequence and continue
TweenManager.Despawn(t, false); TweenManager.Despawn(t, false);

View File

@ -16,7 +16,7 @@ namespace DG.DOTweenEditor.UI
static void ShowWindow() { Open(); } static void ShowWindow() { Open(); }
const string _Title = "DOTween Utility Panel"; const string _Title = "DOTween Utility Panel";
static readonly Vector2 _WinSize = new Vector2(370,490); static readonly Vector2 _WinSize = new Vector2(370,510);
public const string Id = "DOTweenVersion"; public const string Id = "DOTweenVersion";
public const string IdPro = "DOTweenProVersion"; public const string IdPro = "DOTweenProVersion";
static readonly float _HalfBtSize = _WinSize.x * 0.5f - 6; static readonly float _HalfBtSize = _WinSize.x * 0.5f - 6;
@ -124,7 +124,10 @@ namespace DG.DOTweenEditor.UI
switch (_selectedTab) { switch (_selectedTab) {
case 1: case 1:
float labelW = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 160;
DrawPreferencesGUI(); DrawPreferencesGUI();
EditorGUIUtility.labelWidth = labelW;
break; break;
default: default:
DrawSetupGUI(); DrawSetupGUI();
@ -199,6 +202,7 @@ namespace DG.DOTweenEditor.UI
if (GUILayout.Button("Reset", EditorGUIUtils.btBigStyle)) { if (GUILayout.Button("Reset", EditorGUIUtils.btBigStyle)) {
// Reset to original defaults // Reset to original defaults
_src.useSafeMode = true; _src.useSafeMode = true;
_src.safeModeOptions.nestedTweenFailureBehaviour = NestedTweenFailureBehaviour.TryToPreserveSequence;
_src.showUnityEditorReport = false; _src.showUnityEditorReport = false;
_src.timeScale = 1; _src.timeScale = 1;
_src.useSmoothDeltaTime = false; _src.useSmoothDeltaTime = false;
@ -219,13 +223,19 @@ namespace DG.DOTweenEditor.UI
} }
GUILayout.Space(8); GUILayout.Space(8);
_src.useSafeMode = EditorGUILayout.Toggle("Safe Mode", _src.useSafeMode); _src.useSafeMode = EditorGUILayout.Toggle("Safe Mode", _src.useSafeMode);
if (_src.useSafeMode) {
_src.safeModeOptions.nestedTweenFailureBehaviour = (NestedTweenFailureBehaviour)EditorGUILayout.EnumPopup(
new GUIContent("└ On Nested Tween Failure", "Behaviour in case a tween inside a Sequence fails"),
_src.safeModeOptions.nestedTweenFailureBehaviour
);
}
_src.timeScale = EditorGUILayout.FloatField("DOTween's TimeScale", _src.timeScale); _src.timeScale = EditorGUILayout.FloatField("DOTween's TimeScale", _src.timeScale);
_src.useSmoothDeltaTime = EditorGUILayout.Toggle("Smooth DeltaTime", _src.useSmoothDeltaTime); _src.useSmoothDeltaTime = EditorGUILayout.Toggle("Smooth DeltaTime", _src.useSmoothDeltaTime);
_src.maxSmoothUnscaledTime = EditorGUILayout.Slider("Max SmoothUnscaledTime", _src.maxSmoothUnscaledTime, 0.01f, 1f); _src.maxSmoothUnscaledTime = EditorGUILayout.Slider("Max SmoothUnscaledTime", _src.maxSmoothUnscaledTime, 0.01f, 1f);
_src.rewindCallbackMode = (RewindCallbackMode)EditorGUILayout.EnumPopup("OnRewind Callback Mode", _src.rewindCallbackMode); _src.rewindCallbackMode = (RewindCallbackMode)EditorGUILayout.EnumPopup("OnRewind Callback Mode", _src.rewindCallbackMode);
GUILayout.Space(-5); GUILayout.Space(-5);
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
GUILayout.Space(154); GUILayout.Space(EditorGUIUtility.labelWidth + 4);
EditorGUILayout.HelpBox( EditorGUILayout.HelpBox(
_src.rewindCallbackMode == RewindCallbackMode.FireIfPositionChanged _src.rewindCallbackMode == RewindCallbackMode.FireIfPositionChanged
? "When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will be fired only if the tween isn't already rewinded" ? "When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will be fired only if the tween isn't already rewinded"

View File

@ -137,6 +137,17 @@
Public so it can be used by external ease factories Public so it can be used by external ease factories
</summary> </summary>
</member> </member>
<member name="T:DG.Tweening.Core.Enums.NestedTweenFailureBehaviour">
<summary>
Behaviour in case a tween nested inside a Sequence fails
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.NestedTweenFailureBehaviour.TryToPreserveSequence">
<summary>If the Sequence contains other elements, kill the failed tween but preserve the rest</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.NestedTweenFailureBehaviour.KillWholeSequence">
<summary>Kill the whole Sequence</summary>
</member>
<member name="T:DG.Tweening.Core.Enums.UpdateNotice"> <member name="T:DG.Tweening.Core.Enums.UpdateNotice">
<summary> <summary>
Additional notices passed to plugins when updating. Additional notices passed to plugins when updating.
@ -290,6 +301,10 @@
(like targets becoming null while a tween is playing). (like targets becoming null while a tween is playing).
<para>Default: TRUE</para></summary> <para>Default: TRUE</para></summary>
</member> </member>
<member name="F:DG.Tweening.DOTween.nestedTweenFailureBehaviour">
<summary>Behaviour in case a tween nested inside a Sequence fails (caught by safe mode).
<para>Default: NestedTweenFailureBehaviour.TryToPreserveSequence</para></summary>
</member>
<member name="F:DG.Tweening.DOTween.showUnityEditorReport"> <member name="F:DG.Tweening.DOTween.showUnityEditorReport">
<summary>If TRUE you will get a DOTween report when exiting play mode (only in the Editor). <summary>If TRUE you will get a DOTween report when exiting play mode (only in the Editor).
Useful to know how many max Tweeners and Sequences you reached and optimize your final project accordingly. Useful to know how many max Tweeners and Sequences you reached and optimize your final project accordingly.

Binary file not shown.