diff --git a/README.md b/README.md index e7daa86..31b30ab 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Includes a SRP shader for blurring the background of UI panels. #### Using UnityPackageManager (for Unity 2019.3 or later) Open the package manager window (menu: Window > Package Manager)
Select "Add package from git URL...", fill in the pop-up with the following link:
-https://github.com/coryleach/UnityGUI.git#3.0.10
+https://github.com/coryleach/UnityGUI.git#3.0.11
#### Using UnityPackageManager (for Unity 2019.1 or later) @@ -30,7 +30,7 @@ Find the manifest.json file in the Packages folder of your project and edit it t ```js { "dependencies": { - "com.gameframe.gui": "https://github.com/coryleach/UnityGUI.git#3.0.10", + "com.gameframe.gui": "https://github.com/coryleach/UnityGUI.git#3.0.11", ... }, } diff --git a/Runtime/Tween/TweenExtensions.cs b/Runtime/Tween/TweenExtensions.cs index 5240d04..6a1e692 100644 --- a/Runtime/Tween/TweenExtensions.cs +++ b/Runtime/Tween/TweenExtensions.cs @@ -11,9 +11,21 @@ public static class TweenExtensions private static CancellationTokenSource _cancellationTokenSource; private static Dictionary _tweenDict; - private static CancellationToken CancellationToken => _cancellationTokenSource.Token; + private static CancellationToken CancellationToken => (_cancellationTokenSource != null) ? _cancellationTokenSource.Token : CancellationToken.None; - private static bool CanTween => Application.isPlaying && !CancellationToken.IsCancellationRequested; + private static bool CanTween => CanTweenPredicate.Invoke(); + + private static Func _canTweenPredicate = DefaultCanTweenPredicate; + public static Func CanTweenPredicate + { + get => _canTweenPredicate; + set => _canTweenPredicate = value ?? DefaultCanTweenPredicate; + } + + private static bool DefaultCanTweenPredicate() + { + return Application.isPlaying && !CancellationToken.IsCancellationRequested; + } [RuntimeInitializeOnLoadMethod] public static void Initialize() @@ -81,10 +93,16 @@ public static Task DoPunchTweenAsync(int id, float duration, CancellationToken c public static async Task DoTweenAsyncWithLerp(Func lerpMethod, int id, float duration, CancellationToken cancellationToken, Action action, Easing easeType = Easing.Linear, AnimationCurve customCurve = null) { + if (!CanTween) + { + return; + } + var instanceCancellationToken = StartTween(id); float t = 0; var ease = easeType != Easing.CustomCurve ? EaseFunctions.Get(easeType) : customCurve.Evaluate; + action?.Invoke(ease.Invoke(0)); while (t < duration && CanTween) diff --git a/package.json b/package.json index 4018883..57c69c8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.gameframe.gui", "displayName": "Gameframe.GUI", - "version": "3.0.10", + "version": "3.0.11", "description": "This is a library of GUI helpers for UGUI \r\nIncludes a panel system that implements a navigation stack. \r\nIncludes a scene transition system. \r\nIncludes a SRP shader for blurring the background of UI panels.", "keywords": [], "author": {