Skip to content

Commit 35f2957

Browse files
authored
Merge pull request #25 from coryleach/dev
Update tween extensions
2 parents 3990321 + 735fab3 commit 35f2957

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ Includes a SRP shader for blurring the background of UI panels.
2222
#### Using UnityPackageManager (for Unity 2019.3 or later)
2323
Open the package manager window (menu: Window > Package Manager)<br/>
2424
Select "Add package from git URL...", fill in the pop-up with the following link:<br/>
25-
https://github.com/coryleach/UnityGUI.git#3.0.8<br/>
25+
https://github.com/coryleach/UnityGUI.git#3.0.9<br/>
2626

2727
#### Using UnityPackageManager (for Unity 2019.1 or later)
2828

2929
Find the manifest.json file in the Packages folder of your project and edit it to look like this:
3030
```js
3131
{
3232
"dependencies": {
33-
"com.gameframe.gui": "https://github.com/coryleach/UnityGUI.git#3.0.8",
33+
"com.gameframe.gui": "https://github.com/coryleach/UnityGUI.git#3.0.9",
3434
...
3535
},
3636
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Threading.Tasks;
2+
using UnityEngine;
3+
4+
namespace Gameframe.GUI.Tween
5+
{
6+
public static class MaterialTweenExtensions
7+
{
8+
public static async Task DoFloatAsync(this Material material, int propertyId, float startValue, float endValue, float duration, Easing easing = Easing.Linear, AnimationCurve customCurve = null)
9+
{
10+
await TweenExtensions.DoTweenAsync(material.GetInstanceID(), duration, (t) =>
11+
{
12+
material.SetFloat(propertyId, Mathf.Lerp(startValue, endValue, t));
13+
}, easing, customCurve);
14+
}
15+
16+
public static async Task DoFloatAsync(this Material material, string propertyName, float startValue, float endValue, float duration, Easing easing = Easing.Linear, AnimationCurve customCurve = null)
17+
{
18+
var propertyId = Shader.PropertyToID(propertyName);
19+
await TweenExtensions.DoTweenAsync(material.GetInstanceID(), duration, (t) =>
20+
{
21+
material.SetFloat(propertyId, Mathf.Lerp(startValue, endValue, t));
22+
}, easing, customCurve);
23+
}
24+
}
25+
}

Runtime/Tween/MaterialTweenExtensions.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Tween/TweenExtensions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public static void DoKillTweens(this GameObject obj)
4646
}
4747

4848
public static void DoKillTweens(this Component obj)
49+
{
50+
CancelTweensForId(obj.gameObject.GetInstanceID());
51+
}
52+
53+
public static void DoKillTweens(this UnityEngine.Object obj)
4954
{
5055
CancelTweensForId(obj.GetInstanceID());
5156
}
@@ -144,7 +149,7 @@ private static void CompleteTween(int id)
144149
_tweenDict.Remove(id);
145150
}
146151

147-
private static void CancelTweensForId(int id)
152+
public static void CancelTweensForId(int id)
148153
{
149154
if (!_tweenDict.TryGetValue(id, out var tweenData))
150155
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.gameframe.gui",
33
"displayName": "Gameframe.GUI",
4-
"version": "3.0.8",
4+
"version": "3.0.9",
55
"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.",
66
"keywords": [],
77
"author": {

0 commit comments

Comments
 (0)