diff --git a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.XML b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.XML index 558634a..740e2ed 100644 --- a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.XML +++ b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.XML @@ -153,6 +153,27 @@ Lets the plugin know that we restarted or rewinded + + + OnRewind callback behaviour (can only be set via DOTween's Utility Panel) + + + + + When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will be fired only if the tween isn't already rewinded + + + + + When calling Rewind, OnRewind callbacks will always be fired, even if the tween is already rewinded. + When calling PlayBackwards/SmoothRewind instead, OnRewind callbacks will be fired only if the tween isn't already rewinded + + + + + When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will always be fired, even if the tween is already rewinded + + Public only so custom shortcuts can access some of these methods diff --git a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll index 81c6133..c342867 100644 Binary files a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll and b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll differ diff --git a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll.mdb b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll.mdb index aa99046..59c6002 100644 Binary files a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll.mdb and b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll.mdb differ diff --git a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween43.dll b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween43.dll index eeec023..6d45baf 100644 Binary files a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween43.dll and b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween43.dll differ diff --git a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween43.dll.mdb b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween43.dll.mdb index de3d88d..38cce7b 100644 Binary files a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween43.dll.mdb and b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween43.dll.mdb differ diff --git a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween46.dll b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween46.dll index 786b590..3c14ba5 100644 Binary files a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween46.dll and b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween46.dll differ diff --git a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween46.dll.mdb b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween46.dll.mdb index caa4769..d9cfc65 100644 Binary files a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween46.dll.mdb and b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween46.dll.mdb differ diff --git a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween50.dll b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween50.dll index ae636b7..36e9c13 100644 Binary files a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween50.dll and b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween50.dll differ diff --git a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween50.dll.mdb b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween50.dll.mdb index 1fccf09..5e28af3 100644 Binary files a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween50.dll.mdb and b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween50.dll.mdb differ diff --git a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll index f2e5755..b9ec993 100644 Binary files a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll and b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll differ diff --git a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb index 31dc51f..fff46f9 100644 Binary files a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb and b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb differ diff --git a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.XML b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.XML index 558634a..740e2ed 100644 --- a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.XML +++ b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.XML @@ -153,6 +153,27 @@ Lets the plugin know that we restarted or rewinded + + + OnRewind callback behaviour (can only be set via DOTween's Utility Panel) + + + + + When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will be fired only if the tween isn't already rewinded + + + + + When calling Rewind, OnRewind callbacks will always be fired, even if the tween is already rewinded. + When calling PlayBackwards/SmoothRewind instead, OnRewind callbacks will be fired only if the tween isn't already rewinded + + + + + When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will always be fired, even if the tween is already rewinded + + Public only so custom shortcuts can access some of these methods diff --git a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll index 81c6133..c342867 100644 Binary files a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll and b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll differ diff --git a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll.mdb b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll.mdb index aa99046..59c6002 100644 Binary files a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll.mdb and b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll.mdb differ diff --git a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll index eeec023..6d45baf 100644 Binary files a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll and b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll differ diff --git a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll.mdb b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll.mdb index de3d88d..38cce7b 100644 Binary files a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll.mdb and b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween43.dll.mdb differ diff --git a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll index 786b590..3c14ba5 100644 Binary files a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll and b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll differ diff --git a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll.mdb b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll.mdb index caa4769..d9cfc65 100644 Binary files a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll.mdb and b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween46.dll.mdb differ diff --git a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll index ae636b7..36e9c13 100644 Binary files a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll and b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll differ diff --git a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll.mdb b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll.mdb index 1fccf09..5e28af3 100644 Binary files a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll.mdb and b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween50.dll.mdb differ diff --git a/UnityTests.Unity4/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll b/UnityTests.Unity4/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll index f2e5755..b9ec993 100644 Binary files a/UnityTests.Unity4/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll and b/UnityTests.Unity4/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll differ diff --git a/UnityTests.Unity4/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb b/UnityTests.Unity4/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb index 31dc51f..fff46f9 100644 Binary files a/UnityTests.Unity4/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb and b/UnityTests.Unity4/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween Extras/DOTweenExtras.cs b/UnityTests.Unity5/Assets/Demigiant/DOTween Extras/DOTweenExtras.cs index 2436faf..7a8b1e6 100644 --- a/UnityTests.Unity5/Assets/Demigiant/DOTween Extras/DOTweenExtras.cs +++ b/UnityTests.Unity5/Assets/Demigiant/DOTween Extras/DOTweenExtras.cs @@ -15,12 +15,6 @@ namespace DG.Tweening #region Public Methods - #region Commands - - - - #endregion - #region Info Getters /// diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.XML b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.XML index 558634a..740e2ed 100644 --- a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.XML +++ b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.XML @@ -153,6 +153,27 @@ Lets the plugin know that we restarted or rewinded + + + OnRewind callback behaviour (can only be set via DOTween's Utility Panel) + + + + + When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will be fired only if the tween isn't already rewinded + + + + + When calling Rewind, OnRewind callbacks will always be fired, even if the tween is already rewinded. + When calling PlayBackwards/SmoothRewind instead, OnRewind callbacks will be fired only if the tween isn't already rewinded + + + + + When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will always be fired, even if the tween is already rewinded + + Public only so custom shortcuts can access some of these methods diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll index 81c6133..c342867 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll and b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb index aa99046..59c6002 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb and b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll index eeec023..6d45baf 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll and b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll.mdb b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll.mdb index de3d88d..38cce7b 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll.mdb and b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween43.dll.mdb differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll index 786b590..3c14ba5 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll and b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll.mdb b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll.mdb index caa4769..d9cfc65 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll.mdb and b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween46.dll.mdb differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll index ae636b7..36e9c13 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll and b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll.mdb b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll.mdb index 1fccf09..5e28af3 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll.mdb and b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween50.dll.mdb differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll b/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll index f2e5755..b9ec993 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll and b/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb b/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb index 31dc51f..fff46f9 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb and b/UnityTests.Unity5/Assets/Demigiant/DOTween/Editor/DOTweenEditor.dll.mdb differ diff --git a/UnityTests.Unity5/Assets/Resources/DOTweenSettings.asset b/UnityTests.Unity5/Assets/Resources/DOTweenSettings.asset index ea761b5..eb1713d 100644 Binary files a/UnityTests.Unity5/Assets/Resources/DOTweenSettings.asset and b/UnityTests.Unity5/Assets/Resources/DOTweenSettings.asset differ diff --git a/UnityTests.Unity5/Assets/_Tests/RewindCallbackModeTests.cs b/UnityTests.Unity5/Assets/_Tests/RewindCallbackModeTests.cs new file mode 100644 index 0000000..97c77ff --- /dev/null +++ b/UnityTests.Unity5/Assets/_Tests/RewindCallbackModeTests.cs @@ -0,0 +1,44 @@ +using DG.Tweening; +using UnityEngine; + +public class RewindCallbackModeTests : BrainBase +{ + public Transform target; + Tween t; + + void Start() + { + t = target.DOMoveX(3, 2).SetLoops(-1, LoopType.Yoyo).SetAutoKill(false) + .OnRewind(() => Debug.Log("Rewind callback")); + } + + public void Play() + { + t.Play(); + } + + public void PlayForward() + { + t.PlayForward(); + } + + public void Pause() + { + t.Pause(); + } + + public void Rewind() + { + t.Rewind(); + } + + public void PlayBackwards() + { + t.PlayBackwards(); + } + + public void SmoothRewind() + { + t.SmoothRewind(); + } +} \ No newline at end of file diff --git a/UnityTests.Unity5/Assets/_Tests/RewindCallbackModeTests.cs.meta b/UnityTests.Unity5/Assets/_Tests/RewindCallbackModeTests.cs.meta new file mode 100644 index 0000000..3336a52 --- /dev/null +++ b/UnityTests.Unity5/Assets/_Tests/RewindCallbackModeTests.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3a5661fb3240ccb4a9c24e05d8e69848 +timeCreated: 1510143220 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityTests.Unity5/Assets/_Tests/RewindCallbackModeTests.unity b/UnityTests.Unity5/Assets/_Tests/RewindCallbackModeTests.unity new file mode 100644 index 0000000..dafa7e4 Binary files /dev/null and b/UnityTests.Unity5/Assets/_Tests/RewindCallbackModeTests.unity differ diff --git a/UnityTests.Unity5/Assets/_Tests/RewindCallbackModeTests.unity.meta b/UnityTests.Unity5/Assets/_Tests/RewindCallbackModeTests.unity.meta new file mode 100644 index 0000000..cfce230 --- /dev/null +++ b/UnityTests.Unity5/Assets/_Tests/RewindCallbackModeTests.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: da4a35ead044f0a4d8abba797d0f1393 +timeCreated: 1510143210 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/_DOTween.Assembly/DOTween/Core/DOTweenSettings.cs b/_DOTween.Assembly/DOTween/Core/DOTweenSettings.cs index 33fd852..0977fd2 100644 --- a/_DOTween.Assembly/DOTween/Core/DOTweenSettings.cs +++ b/_DOTween.Assembly/DOTween/Core/DOTweenSettings.cs @@ -1,6 +1,7 @@ // Author: Daniele Giardini - http://www.demigiant.com // Created: 2015/02/05 10:28 +using DG.Tweening.Core.Enums; using UnityEngine; #pragma warning disable 1591 @@ -14,6 +15,7 @@ namespace DG.Tweening.Core public float timeScale = 1; public bool useSmoothDeltaTime; public float maxSmoothUnscaledTime = 0.15f; // Used if useSmoothDeltaTime is TRUE + public RewindCallbackMode rewindCallbackMode = RewindCallbackMode.FireIfPositionChanged; public bool showUnityEditorReport; public LogBehaviour logBehaviour = LogBehaviour.ErrorsOnly; public bool drawGizmos = true; diff --git a/_DOTween.Assembly/DOTween/Core/Enums/RewindCallbackMode.cs b/_DOTween.Assembly/DOTween/Core/Enums/RewindCallbackMode.cs new file mode 100644 index 0000000..87fea92 --- /dev/null +++ b/_DOTween.Assembly/DOTween/Core/Enums/RewindCallbackMode.cs @@ -0,0 +1,26 @@ +// Author: Daniele Giardini - http://www.demigiant.com +// Created: 2017/11/08 12:28 +// License Copyright (c) Daniele Giardini +// This work is subject to the terms at http://dotween.demigiant.com/license.php +namespace DG.Tweening.Core.Enums +{ + /// + /// OnRewind callback behaviour (can only be set via DOTween's Utility Panel) + /// + public enum RewindCallbackMode + { + /// + /// When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will be fired only if the tween isn't already rewinded + /// + FireIfPositionChanged, + /// + /// When calling Rewind, OnRewind callbacks will always be fired, even if the tween is already rewinded. + /// When calling PlayBackwards/SmoothRewind instead, OnRewind callbacks will be fired only if the tween isn't already rewinded + /// + FireAlwaysWithRewind, + /// + /// When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will always be fired, even if the tween is already rewinded + /// + FireAlways, + } +} \ No newline at end of file diff --git a/_DOTween.Assembly/DOTween/Core/TweenManager.cs b/_DOTween.Assembly/DOTween/Core/TweenManager.cs index 3430b24..e933459 100644 --- a/_DOTween.Assembly/DOTween/Core/TweenManager.cs +++ b/_DOTween.Assembly/DOTween/Core/TweenManager.cs @@ -674,6 +674,10 @@ namespace DG.Tweening.Core internal static bool PlayBackwards(Tween t) { + if (t.completedLoops == 0 && t.position <= 0) { + // Already rewinded, manage OnRewind callback + ManageOnRewindCallbackWhenAlreadyRewinded(t, true); + } if (!t.isBackwards) { t.isBackwards = true; Play(t); @@ -726,6 +730,9 @@ namespace DG.Tweening.Core rewinded = true; bool needsKilling = Tween.DoGoto(t, 0, 0, UpdateMode.Goto); if (!needsKilling && wasPlaying && t.onPause != null) Tween.OnTweenCallback(t.onPause); + } else { + // Alread rewinded + ManageOnRewindCallbackWhenAlreadyRewinded(t, false); } return rewinded; } @@ -745,7 +752,11 @@ namespace DG.Tweening.Core t.Goto(t.ElapsedDirectionalPercentage() * t.duration); t.PlayBackwards(); } - } else t.isPlaying = false; + } else { + // Already rewinded + t.isPlaying = false; + ManageOnRewindCallbackWhenAlreadyRewinded(t, true); + } return rewinded; } @@ -1011,6 +1022,23 @@ namespace DG.Tweening.Core if (killAdd > 0) _KillList.Capacity += killAdd; } + #region Helpers + + // If isPlayBackwardsOrSmoothRewind is FALSE, it means this was a Rewind command + static void ManageOnRewindCallbackWhenAlreadyRewinded(Tween t, bool isPlayBackwardsOrSmoothRewind) + { + if (t.onRewind == null) return; + if (isPlayBackwardsOrSmoothRewind) { + // PlayBackwards or SmoothRewind + if (DOTween.rewindCallbackMode == RewindCallbackMode.FireAlways) t.onRewind(); + } else { + // Rewind + if (DOTween.rewindCallbackMode != RewindCallbackMode.FireIfPositionChanged) t.onRewind(); + } + } + + #endregion + #endregion #region Debug Methods diff --git a/_DOTween.Assembly/DOTween/DOTween.cs b/_DOTween.Assembly/DOTween/DOTween.cs index 3aa2587..a76da0a 100644 --- a/_DOTween.Assembly/DOTween/DOTween.cs +++ b/_DOTween.Assembly/DOTween/DOTween.cs @@ -59,6 +59,8 @@ namespace DG.Tweening /// Setting this to TRUE will lead to smoother animations. /// Default: FALSE public static float maxSmoothUnscaledTime = 0.15f; + // Internal ► Can only be set via DOTween's Utility Panel + internal static RewindCallbackMode rewindCallbackMode = RewindCallbackMode.FireIfPositionChanged; /// DOTween's log behaviour. /// Default: LogBehaviour.ErrorsOnly public static LogBehaviour logBehaviour { @@ -180,6 +182,7 @@ namespace DG.Tweening DOTween.timeScale = settings.timeScale; DOTween.useSmoothDeltaTime = settings.useSmoothDeltaTime; DOTween.maxSmoothUnscaledTime = settings.maxSmoothUnscaledTime; + DOTween.rewindCallbackMode = settings.rewindCallbackMode; DOTween.defaultRecyclable = recycleAllByDefault == null ? settings.defaultRecyclable : (bool)recycleAllByDefault; DOTween.showUnityEditorReport = settings.showUnityEditorReport; DOTween.drawGizmos = settings.drawGizmos; diff --git a/_DOTween.Assembly/DOTween/DOTween.csproj b/_DOTween.Assembly/DOTween/DOTween.csproj index fcc9190..ae70277 100644 --- a/_DOTween.Assembly/DOTween/DOTween.csproj +++ b/_DOTween.Assembly/DOTween/DOTween.csproj @@ -114,6 +114,7 @@ + diff --git a/_DOTween.Assembly/DOTweenEditor/DOTweenUtilityWindow.cs b/_DOTween.Assembly/DOTweenEditor/DOTweenUtilityWindow.cs index d139cb5..e89ec0b 100644 --- a/_DOTween.Assembly/DOTweenEditor/DOTweenUtilityWindow.cs +++ b/_DOTween.Assembly/DOTweenEditor/DOTweenUtilityWindow.cs @@ -6,6 +6,7 @@ using System.Reflection; using DG.DOTweenEditor.Core; using DG.Tweening; using DG.Tweening.Core; +using DG.Tweening.Core.Enums; using UnityEditor; using UnityEngine; @@ -75,7 +76,7 @@ namespace DG.DOTweenEditor static void ShowWindow() { Open(); } const string _Title = "DOTween Utility Panel"; - static readonly Vector2 _WinSize = new Vector2(300,421); + static readonly Vector2 _WinSize = new Vector2(370,490); public const string Id = "DOTweenVersion"; public const string IdPro = "DOTweenProVersion"; static readonly float _HalfBtSize = _WinSize.x * 0.5f - 6; @@ -203,6 +204,7 @@ namespace DG.DOTweenEditor _src.timeScale = 1; _src.useSmoothDeltaTime = false; _src.maxSmoothUnscaledTime = 0.15f; + _src.rewindCallbackMode = RewindCallbackMode.FireIfPositionChanged; _src.logBehaviour = LogBehaviour.ErrorsOnly; _src.drawGizmos = true; _src.defaultRecyclable = false; @@ -221,6 +223,19 @@ namespace DG.DOTweenEditor _src.timeScale = EditorGUILayout.FloatField("DOTween's TimeScale", _src.timeScale); _src.useSmoothDeltaTime = EditorGUILayout.Toggle("Smooth DeltaTime", _src.useSmoothDeltaTime); _src.maxSmoothUnscaledTime = EditorGUILayout.Slider("Max SmoothUnscaledTime", _src.maxSmoothUnscaledTime, 0.01f, 1f); + _src.rewindCallbackMode = (RewindCallbackMode)EditorGUILayout.EnumPopup("OnRewind Callback Mode", _src.rewindCallbackMode); + GUILayout.Space(-5); + GUILayout.BeginHorizontal(); + GUILayout.Space(154); + EditorGUILayout.HelpBox( + _src.rewindCallbackMode == RewindCallbackMode.FireIfPositionChanged + ? "When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will be fired only if the tween isn't already rewinded" + : _src.rewindCallbackMode == RewindCallbackMode.FireAlwaysWithRewind + ? "When calling Rewind, OnRewind callbacks will always be fired, even if the tween is already rewinded." + : "When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will always be fired, even if the tween is already rewinded", + MessageType.None + ); + GUILayout.EndHorizontal(); _src.showUnityEditorReport = EditorGUILayout.Toggle("Editor Report", _src.showUnityEditorReport); _src.logBehaviour = (LogBehaviour)EditorGUILayout.EnumPopup("Log Behaviour", _src.logBehaviour); _src.drawGizmos = EditorGUILayout.Toggle("Draw Path Gizmos", _src.drawGizmos); diff --git a/_DOTween.Assembly/bin/DOTween.XML b/_DOTween.Assembly/bin/DOTween.XML index 558634a..740e2ed 100644 --- a/_DOTween.Assembly/bin/DOTween.XML +++ b/_DOTween.Assembly/bin/DOTween.XML @@ -153,6 +153,27 @@ Lets the plugin know that we restarted or rewinded + + + OnRewind callback behaviour (can only be set via DOTween's Utility Panel) + + + + + When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will be fired only if the tween isn't already rewinded + + + + + When calling Rewind, OnRewind callbacks will always be fired, even if the tween is already rewinded. + When calling PlayBackwards/SmoothRewind instead, OnRewind callbacks will be fired only if the tween isn't already rewinded + + + + + When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will always be fired, even if the tween is already rewinded + + Public only so custom shortcuts can access some of these methods diff --git a/_DOTween.Assembly/bin/DOTween.dll b/_DOTween.Assembly/bin/DOTween.dll index 81c6133..c342867 100644 Binary files a/_DOTween.Assembly/bin/DOTween.dll and b/_DOTween.Assembly/bin/DOTween.dll differ diff --git a/_DOTween.Assembly/bin/DOTween.dll.mdb b/_DOTween.Assembly/bin/DOTween.dll.mdb index aa99046..59c6002 100644 Binary files a/_DOTween.Assembly/bin/DOTween.dll.mdb and b/_DOTween.Assembly/bin/DOTween.dll.mdb differ diff --git a/_DOTween.Assembly/bin/DOTween43.dll b/_DOTween.Assembly/bin/DOTween43.dll index eeec023..6d45baf 100644 Binary files a/_DOTween.Assembly/bin/DOTween43.dll and b/_DOTween.Assembly/bin/DOTween43.dll differ diff --git a/_DOTween.Assembly/bin/DOTween43.dll.mdb b/_DOTween.Assembly/bin/DOTween43.dll.mdb index de3d88d..38cce7b 100644 Binary files a/_DOTween.Assembly/bin/DOTween43.dll.mdb and b/_DOTween.Assembly/bin/DOTween43.dll.mdb differ diff --git a/_DOTween.Assembly/bin/DOTween46.dll b/_DOTween.Assembly/bin/DOTween46.dll index 786b590..3c14ba5 100644 Binary files a/_DOTween.Assembly/bin/DOTween46.dll and b/_DOTween.Assembly/bin/DOTween46.dll differ diff --git a/_DOTween.Assembly/bin/DOTween46.dll.mdb b/_DOTween.Assembly/bin/DOTween46.dll.mdb index caa4769..d9cfc65 100644 Binary files a/_DOTween.Assembly/bin/DOTween46.dll.mdb and b/_DOTween.Assembly/bin/DOTween46.dll.mdb differ diff --git a/_DOTween.Assembly/bin/DOTween50.dll b/_DOTween.Assembly/bin/DOTween50.dll index ae636b7..36e9c13 100644 Binary files a/_DOTween.Assembly/bin/DOTween50.dll and b/_DOTween.Assembly/bin/DOTween50.dll differ diff --git a/_DOTween.Assembly/bin/DOTween50.dll.mdb b/_DOTween.Assembly/bin/DOTween50.dll.mdb index 1fccf09..5e28af3 100644 Binary files a/_DOTween.Assembly/bin/DOTween50.dll.mdb and b/_DOTween.Assembly/bin/DOTween50.dll.mdb differ diff --git a/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll b/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll index f2e5755..b9ec993 100644 Binary files a/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll and b/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll differ diff --git a/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll.mdb b/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll.mdb index 31dc51f..fff46f9 100644 Binary files a/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll.mdb and b/_DOTween.Assembly/bin/Editor/DOTweenEditor.dll.mdb differ