Skip to content

Commit 4a89495

Browse files
committed
Fixing a bug that could prevent killing tweens in some instances
1 parent 79f573a commit 4a89495

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

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: 5 additions & 0 deletions
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
}

0 commit comments

Comments
 (0)