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

Added RewindCallbackMode in DOTweenUtilityPanel (and implemented in runtime code)

This commit is contained in:
Demigiant 2017-11-08 13:33:53 +01:00
parent 243571f908
commit 1d13d54289
56 changed files with 225 additions and 8 deletions

View File

@ -153,6 +153,27 @@
Lets the plugin know that we restarted or rewinded
</summary>
</member>
<member name="T:DG.Tweening.Core.Enums.RewindCallbackMode">
<summary>
OnRewind callback behaviour (can only be set via DOTween's Utility Panel)
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.RewindCallbackMode.FireIfPositionChanged">
<summary>
When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will be fired only if the tween isn't already rewinded
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.RewindCallbackMode.FireAlwaysWithRewind">
<summary>
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
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.RewindCallbackMode.FireAlways">
<summary>
When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will always be fired, even if the tween is already rewinded
</summary>
</member>
<member name="T:DG.Tweening.Core.Extensions">
<summary>
Public only so custom shortcuts can access some of these methods

View File

@ -153,6 +153,27 @@
Lets the plugin know that we restarted or rewinded
</summary>
</member>
<member name="T:DG.Tweening.Core.Enums.RewindCallbackMode">
<summary>
OnRewind callback behaviour (can only be set via DOTween's Utility Panel)
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.RewindCallbackMode.FireIfPositionChanged">
<summary>
When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will be fired only if the tween isn't already rewinded
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.RewindCallbackMode.FireAlwaysWithRewind">
<summary>
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
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.RewindCallbackMode.FireAlways">
<summary>
When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will always be fired, even if the tween is already rewinded
</summary>
</member>
<member name="T:DG.Tweening.Core.Extensions">
<summary>
Public only so custom shortcuts can access some of these methods

View File

@ -15,12 +15,6 @@ namespace DG.Tweening
#region Public Methods
#region Commands
#endregion
#region Info Getters
/// <summary>

View File

@ -153,6 +153,27 @@
Lets the plugin know that we restarted or rewinded
</summary>
</member>
<member name="T:DG.Tweening.Core.Enums.RewindCallbackMode">
<summary>
OnRewind callback behaviour (can only be set via DOTween's Utility Panel)
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.RewindCallbackMode.FireIfPositionChanged">
<summary>
When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will be fired only if the tween isn't already rewinded
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.RewindCallbackMode.FireAlwaysWithRewind">
<summary>
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
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.RewindCallbackMode.FireAlways">
<summary>
When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will always be fired, even if the tween is already rewinded
</summary>
</member>
<member name="T:DG.Tweening.Core.Extensions">
<summary>
Public only so custom shortcuts can access some of these methods

View File

@ -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("<color=#00ff00>Rewind callback</color>"));
}
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();
}
}

View File

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

View File

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

View File

@ -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;

View File

@ -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
{
/// <summary>
/// OnRewind callback behaviour (can only be set via DOTween's Utility Panel)
/// </summary>
public enum RewindCallbackMode
{
/// <summary>
/// When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will be fired only if the tween isn't already rewinded
/// </summary>
FireIfPositionChanged,
/// <summary>
/// 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
/// </summary>
FireAlwaysWithRewind,
/// <summary>
/// When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will always be fired, even if the tween is already rewinded
/// </summary>
FireAlways,
}
}

View File

@ -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

View File

@ -59,6 +59,8 @@ namespace DG.Tweening
/// Setting this to TRUE will lead to smoother animations.
/// <para>Default: FALSE</para></summary>
public static float maxSmoothUnscaledTime = 0.15f;
// Internal ► Can only be set via DOTween's Utility Panel
internal static RewindCallbackMode rewindCallbackMode = RewindCallbackMode.FireIfPositionChanged;
/// <summary>DOTween's log behaviour.
/// <para>Default: LogBehaviour.ErrorsOnly</para></summary>
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;

View File

@ -114,6 +114,7 @@
<Compile Include="Plugins\PathPlugin.cs" />
<Compile Include="Plugins\Vector3WrapperPlugin.cs" />
<Compile Include="Plugins\Vector4WrapperPlugin.cs" />
<Compile Include="Core\Enums\RewindCallbackMode.cs" />
<Compile Include="RotateMode.cs" />
<Compile Include="ScrambleMode.cs" />
<Compile Include="TweenExtensions.cs" />

View File

@ -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);

View File

@ -153,6 +153,27 @@
Lets the plugin know that we restarted or rewinded
</summary>
</member>
<member name="T:DG.Tweening.Core.Enums.RewindCallbackMode">
<summary>
OnRewind callback behaviour (can only be set via DOTween's Utility Panel)
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.RewindCallbackMode.FireIfPositionChanged">
<summary>
When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will be fired only if the tween isn't already rewinded
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.RewindCallbackMode.FireAlwaysWithRewind">
<summary>
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
</summary>
</member>
<member name="F:DG.Tweening.Core.Enums.RewindCallbackMode.FireAlways">
<summary>
When calling Rewind or PlayBackwards/SmoothRewind, OnRewind callbacks will always be fired, even if the tween is already rewinded
</summary>
</member>
<member name="T:DG.Tweening.Core.Extensions">
<summary>
Public only so custom shortcuts can access some of these methods

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.