mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-20 09:16:02 +08:00
[DOTweenEditorPreview] Better reset management
This commit is contained in:
parent
cdc4b68f53
commit
af057d7fcc
Binary file not shown.
Binary file not shown.
@ -12,9 +12,9 @@
|
||||
</member>
|
||||
<member name="M:DG.DOTweenEditor.DOTweenEditorPreview.Stop(System.Boolean)">
|
||||
<summary>
|
||||
Stops the update loop and clears any callback.
|
||||
Stops the update loop and clears the onPreviewUpdated callback.
|
||||
</summary>
|
||||
<param name="reset">If TRUE also resets the tweened objects to their original state</param>
|
||||
<param name="resetTweenTargets">If TRUE also resets the tweened objects to their original state</param>
|
||||
</member>
|
||||
<member name="M:DG.DOTweenEditor.DOTweenEditorPreview.PrepareTweenForPreview(DG.Tweening.Tween,System.Boolean,System.Boolean,System.Boolean)">
|
||||
<summary>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -32,7 +32,7 @@ namespace DG.Tweening
|
||||
public class DOTween
|
||||
{
|
||||
/// <summary>DOTween's version</summary>
|
||||
public static readonly string Version = "1.2.140"; // Last version before modules: 1.1.755
|
||||
public static readonly string Version = "1.2.145"; // Last version before modules: 1.1.755
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Options ////////////////////////////////////
|
||||
|
||||
@ -18,11 +18,11 @@ namespace DG.DOTweenEditor
|
||||
static double _previewTime;
|
||||
static Action _onPreviewUpdated;
|
||||
static GameObject _previewObj; // Used so it can be set dirty (otherwise canvas-only tweens won't refresh the view)
|
||||
static readonly List<Tween> _tweens = new List<Tween>();
|
||||
static readonly List<Tween> _Tweens = new List<Tween>();
|
||||
|
||||
static DOTweenEditorPreview()
|
||||
{
|
||||
Clear();
|
||||
ClearPreviewObject();
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
@ -43,27 +43,26 @@ namespace DG.DOTweenEditor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the update loop and clears any callback.
|
||||
/// Stops the update loop and clears the onPreviewUpdated callback.
|
||||
/// </summary>
|
||||
/// <param name="reset">If TRUE also resets the tweened objects to their original state</param>
|
||||
public static void Stop(bool reset = false)
|
||||
/// <param name="resetTweenTargets">If TRUE also resets the tweened objects to their original state</param>
|
||||
public static void Stop(bool resetTweenTargets = false)
|
||||
{
|
||||
_isPreviewing = false;
|
||||
EditorApplication.update -= PreviewUpdate;
|
||||
_onPreviewUpdated = null;
|
||||
if (reset) {
|
||||
foreach (Tween t in _tweens) {
|
||||
if (t != null && t.active) {
|
||||
if (resetTweenTargets) {
|
||||
foreach (Tween t in _Tweens) {
|
||||
try {
|
||||
if (t.isFrom) t.Complete();
|
||||
else t.Rewind();
|
||||
} catch {
|
||||
// Just skip
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Clear();
|
||||
ValidateTweens();
|
||||
ClearPreviewObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -75,7 +74,7 @@ namespace DG.DOTweenEditor
|
||||
/// <param name="andPlay">If TRUE starts playing the tween immediately</param>
|
||||
public static void PrepareTweenForPreview(Tween t, bool clearCallbacks = true, bool preventAutoKill = true, bool andPlay = true)
|
||||
{
|
||||
_tweens.Add(t);
|
||||
_Tweens.Add(t);
|
||||
t.SetUpdate(UpdateType.Manual);
|
||||
if (preventAutoKill) t.SetAutoKill(false);
|
||||
if (clearCallbacks) {
|
||||
@ -90,10 +89,9 @@ namespace DG.DOTweenEditor
|
||||
|
||||
#region Methods
|
||||
|
||||
static void Clear()
|
||||
static void ClearPreviewObject()
|
||||
{
|
||||
_previewObj = null;
|
||||
_tweens.Clear();
|
||||
// Find and destroy any existing preview objects
|
||||
PreviewComponent[] objs = Object.FindObjectsOfType<PreviewComponent>();
|
||||
for (int i = 0; i < objs.Length; ++i) Object.DestroyImmediate(objs[i].gameObject);
|
||||
@ -111,6 +109,13 @@ namespace DG.DOTweenEditor
|
||||
if (_onPreviewUpdated != null) _onPreviewUpdated();
|
||||
}
|
||||
|
||||
static void ValidateTweens()
|
||||
{
|
||||
for (int i = _Tweens.Count - 1; i > -1; --i) {
|
||||
if (_Tweens[i] == null || !_Tweens[i].active) _Tweens.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -12,9 +12,9 @@
|
||||
</member>
|
||||
<member name="M:DG.DOTweenEditor.DOTweenEditorPreview.Stop(System.Boolean)">
|
||||
<summary>
|
||||
Stops the update loop and clears any callback.
|
||||
Stops the update loop and clears the onPreviewUpdated callback.
|
||||
</summary>
|
||||
<param name="reset">If TRUE also resets the tweened objects to their original state</param>
|
||||
<param name="resetTweenTargets">If TRUE also resets the tweened objects to their original state</param>
|
||||
</member>
|
||||
<member name="M:DG.DOTweenEditor.DOTweenEditorPreview.PrepareTweenForPreview(DG.Tweening.Tween,System.Boolean,System.Boolean,System.Boolean)">
|
||||
<summary>
|
||||
|
||||
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