From 4a89495ad7872d4e9b8505c86c464c4413c28370 Mon Sep 17 00:00:00 2001 From: Cory Leach Date: Thu, 14 Sep 2023 15:01:03 -0500 Subject: [PATCH 1/3] Fixing a bug that could prevent killing tweens in some instances --- Runtime/Tween/MaterialTweenExtensions.cs | 25 +++++++++++++++++++ Runtime/Tween/MaterialTweenExtensions.cs.meta | 3 +++ Runtime/Tween/TweenExtensions.cs | 5 ++++ 3 files changed, 33 insertions(+) create mode 100644 Runtime/Tween/MaterialTweenExtensions.cs create mode 100644 Runtime/Tween/MaterialTweenExtensions.cs.meta diff --git a/Runtime/Tween/MaterialTweenExtensions.cs b/Runtime/Tween/MaterialTweenExtensions.cs new file mode 100644 index 0000000..01604f1 --- /dev/null +++ b/Runtime/Tween/MaterialTweenExtensions.cs @@ -0,0 +1,25 @@ +using System.Threading.Tasks; +using UnityEngine; + +namespace Gameframe.GUI.Tween +{ + public static class MaterialTweenExtensions + { + public static async Task DoFloatAsync(this Material material, int propertyId, float startValue, float endValue, float duration, Easing easing = Easing.Linear, AnimationCurve customCurve = null) + { + await TweenExtensions.DoTweenAsync(material.GetInstanceID(), duration, (t) => + { + material.SetFloat(propertyId, Mathf.Lerp(startValue, endValue, t)); + }, easing, customCurve); + } + + public static async Task DoFloatAsync(this Material material, string propertyName, float startValue, float endValue, float duration, Easing easing = Easing.Linear, AnimationCurve customCurve = null) + { + var propertyId = Shader.PropertyToID(propertyName); + await TweenExtensions.DoTweenAsync(material.GetInstanceID(), duration, (t) => + { + material.SetFloat(propertyId, Mathf.Lerp(startValue, endValue, t)); + }, easing, customCurve); + } + } +} \ No newline at end of file diff --git a/Runtime/Tween/MaterialTweenExtensions.cs.meta b/Runtime/Tween/MaterialTweenExtensions.cs.meta new file mode 100644 index 0000000..ad17c95 --- /dev/null +++ b/Runtime/Tween/MaterialTweenExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ef48324267f24a82b86aeb8d601d0284 +timeCreated: 1694451375 \ No newline at end of file diff --git a/Runtime/Tween/TweenExtensions.cs b/Runtime/Tween/TweenExtensions.cs index 76b728f..37b634e 100644 --- a/Runtime/Tween/TweenExtensions.cs +++ b/Runtime/Tween/TweenExtensions.cs @@ -46,6 +46,11 @@ public static void DoKillTweens(this GameObject obj) } public static void DoKillTweens(this Component obj) + { + CancelTweensForId(obj.gameObject.GetInstanceID()); + } + + public static void DoKillTweens(this UnityEngine.Object obj) { CancelTweensForId(obj.GetInstanceID()); } From c5756fb7e58a4a47d1af03e7157234282b0b955b Mon Sep 17 00:00:00 2001 From: Cory Leach Date: Thu, 14 Sep 2023 15:02:56 -0500 Subject: [PATCH 2/3] Exposing CancelTweensForId for use in external extensions --- Runtime/Tween/TweenExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Runtime/Tween/TweenExtensions.cs b/Runtime/Tween/TweenExtensions.cs index 37b634e..28b1a70 100644 --- a/Runtime/Tween/TweenExtensions.cs +++ b/Runtime/Tween/TweenExtensions.cs @@ -149,7 +149,7 @@ private static void CompleteTween(int id) _tweenDict.Remove(id); } - private static void CancelTweensForId(int id) + public static void CancelTweensForId(int id) { if (!_tweenDict.TryGetValue(id, out var tweenData)) { From 735fab3e08f783eddea27a4f773e45f8f684d23f Mon Sep 17 00:00:00 2001 From: Cory Leach Date: Thu, 14 Sep 2023 15:05:13 -0500 Subject: [PATCH 3/3] Package bump --- README.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f2ed31c..a62cb2b 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.8
+https://github.com/coryleach/UnityGUI.git#3.0.9
#### 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.8", + "com.gameframe.gui": "https://github.com/coryleach/UnityGUI.git#3.0.9", ... }, } diff --git a/package.json b/package.json index 48471f3..27a0a1a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.gameframe.gui", "displayName": "Gameframe.GUI", - "version": "3.0.8", + "version": "3.0.9", "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": {