mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-20 17:26:03 +08:00
[DOTweenEditorPreview] Added optional reset parameter to Stop method
This commit is contained in:
parent
9beae472ee
commit
cdc4b68f53
BIN
EditorPreviewExample.unitypackage
Normal file
BIN
EditorPreviewExample.unitypackage
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -10,10 +10,11 @@
|
||||
</summary>
|
||||
<param name="onPreviewUpdated">Eventual callback to call after every update</param>
|
||||
</member>
|
||||
<member name="M:DG.DOTweenEditor.DOTweenEditorPreview.Stop">
|
||||
<member name="M:DG.DOTweenEditor.DOTweenEditorPreview.Stop(System.Boolean)">
|
||||
<summary>
|
||||
Stops the update loop and clears any callback.
|
||||
</summary>
|
||||
<param name="reset">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.
@ -3,22 +3,143 @@ guid: 15321a018ba7b9f49a6442a41ee5dc70
|
||||
timeCreated: 1431691487
|
||||
licenseType: Free
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
WindowsStoreApps:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude LinuxUniversal: 1
|
||||
Exclude OSXIntel: 1
|
||||
Exclude OSXIntel64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 1
|
||||
data:
|
||||
first:
|
||||
'': Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
OS: AnyOS
|
||||
data:
|
||||
first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
data:
|
||||
first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
data:
|
||||
first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
data:
|
||||
first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXIntel64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
data:
|
||||
first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
data:
|
||||
first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>DOTweenUpgradeManager</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:DG.DOTweenUpgradeManager.Autorun">
|
||||
<summary>
|
||||
This class and its whole library are deleted the first time DOTween's setup is run after an upgrade (or after a new install).
|
||||
NOTE: DidReloadScripts doesn't work on first install so it's useless, InitializeOnLoad is the only way
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b9c6b17aec073847a9d34c432a148ec
|
||||
timeCreated: 1544961652
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56bca508bd08a4f44a507f17e7577afb
|
||||
timeCreated: 1544961640
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,34 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7602d66796c87a4fac3013913374c07
|
||||
timeCreated: 1544961644
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
data:
|
||||
first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d133da273ec4fd14a950eacbb83e0db0
|
||||
folderAsset: yes
|
||||
timeCreated: 1544961756
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c182c00b8a3c73343bc70c4936be00c7
|
||||
timeCreated: 1544961756
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9180dc17e23b01144acbef7fbf36319d
|
||||
folderAsset: yes
|
||||
timeCreated: 1544961905
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,33 @@
|
||||
using DG.DOTweenEditor;
|
||||
using DG.Tweening;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public static class EditorPreviewer
|
||||
{
|
||||
static EditorPreviewer()
|
||||
{
|
||||
TweenManager.OnEditorPreviewPrepareTweenCommand += PrepareTween;
|
||||
TweenManager.OnEditorPreviewPlayCommand += Play;
|
||||
TweenManager.OnEditorPreviewStopCommand += Stop;
|
||||
}
|
||||
|
||||
static void PrepareTween(Tween t)
|
||||
{
|
||||
Debug.Log("EditorPreviewer ► AddTween");
|
||||
DOTweenEditorPreview.PrepareTweenForPreview(t);
|
||||
}
|
||||
|
||||
static void Play()
|
||||
{
|
||||
Debug.Log("EditorPreviewer ► Play");
|
||||
DOTweenEditorPreview.Start();
|
||||
}
|
||||
|
||||
static void Stop()
|
||||
{
|
||||
Debug.Log("EditorPreviewer ► Stop and reset");
|
||||
DOTweenEditorPreview.Stop(true);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f78c9bfa83e26014a81b98375dad6759
|
||||
timeCreated: 1544961917
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class TweenManager : MonoBehaviour
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
#region Editor-only Events
|
||||
|
||||
public static event Action<Tween> OnEditorPreviewPrepareTweenCommand;
|
||||
public static event Action OnEditorPreviewPlayCommand;
|
||||
public static event Action OnEditorPreviewStopCommand;
|
||||
static void Dispatch_OnEditorPreviewPrepareTweenCommand(Tween t) { if (OnEditorPreviewPrepareTweenCommand != null) OnEditorPreviewPrepareTweenCommand(t); }
|
||||
static void Dispatch_OnEditorPreviewPlayCommand() { if (OnEditorPreviewPlayCommand != null) OnEditorPreviewPlayCommand(); }
|
||||
static void Dispatch_OnEditorPreviewStopCommand() { if (OnEditorPreviewStopCommand != null) OnEditorPreviewStopCommand(); }
|
||||
|
||||
#endregion
|
||||
#endif
|
||||
|
||||
#region Serialized
|
||||
|
||||
[SerializeField] Transform[] targets;
|
||||
|
||||
#endregion
|
||||
|
||||
Tween[] tweens;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (targets == null) return;
|
||||
|
||||
tweens = new Tween[targets.Length];
|
||||
for (int i = 0; i < targets.Length; ++i) {
|
||||
tweens[i] = targets[i].DOMoveX(5, 2);
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) Dispatch_OnEditorPreviewPrepareTweenCommand(tweens[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) Dispatch_OnEditorPreviewPlayCommand();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) Dispatch_OnEditorPreviewStopCommand();
|
||||
#endif
|
||||
|
||||
// Kill all tweens
|
||||
foreach (Tween t in tweens) t.Kill();
|
||||
tweens = null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc5fd5cd5cb3ed74aaf5581919d6bae2
|
||||
timeCreated: 1544961895
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -32,7 +32,7 @@ namespace DG.Tweening
|
||||
public class DOTween
|
||||
{
|
||||
/// <summary>DOTween's version</summary>
|
||||
public static readonly string Version = "1.2.135"; // Last version before modules: 1.1.755
|
||||
public static readonly string Version = "1.2.140"; // Last version before modules: 1.1.755
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Options ////////////////////////////////////
|
||||
|
||||
@ -18,6 +18,7 @@ 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 DOTweenEditorPreview()
|
||||
{
|
||||
@ -44,11 +45,24 @@ namespace DG.DOTweenEditor
|
||||
/// <summary>
|
||||
/// Stops the update loop and clears any callback.
|
||||
/// </summary>
|
||||
public static void Stop()
|
||||
/// <param name="reset">If TRUE also resets the tweened objects to their original state</param>
|
||||
public static void Stop(bool reset = false)
|
||||
{
|
||||
_isPreviewing = false;
|
||||
EditorApplication.update -= PreviewUpdate;
|
||||
_onPreviewUpdated = null;
|
||||
if (reset) {
|
||||
foreach (Tween t in _tweens) {
|
||||
if (t != null && t.active) {
|
||||
try {
|
||||
if (t.isFrom) t.Complete();
|
||||
else t.Rewind();
|
||||
} catch {
|
||||
// Just skip
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Clear();
|
||||
}
|
||||
|
||||
@ -61,6 +75,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);
|
||||
t.SetUpdate(UpdateType.Manual);
|
||||
if (preventAutoKill) t.SetAutoKill(false);
|
||||
if (clearCallbacks) {
|
||||
@ -78,6 +93,7 @@ namespace DG.DOTweenEditor
|
||||
static void Clear()
|
||||
{
|
||||
_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);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -10,10 +10,11 @@
|
||||
</summary>
|
||||
<param name="onPreviewUpdated">Eventual callback to call after every update</param>
|
||||
</member>
|
||||
<member name="M:DG.DOTweenEditor.DOTweenEditorPreview.Stop">
|
||||
<member name="M:DG.DOTweenEditor.DOTweenEditorPreview.Stop(System.Boolean)">
|
||||
<summary>
|
||||
Stops the update loop and clears any callback.
|
||||
</summary>
|
||||
<param name="reset">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