From 26e4dc3a35d9c778684388de1af8b3f288fe627d Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 28 May 2021 20:00:48 +0800 Subject: *Tween --- .../Scripts/Animation/Tween/TweenModule_Alpha.cs | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Assets/UI_Extension/Scripts/Animation/Tween/TweenModule_Alpha.cs (limited to 'Assets/UI_Extension/Scripts/Animation/Tween/TweenModule_Alpha.cs') diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/TweenModule_Alpha.cs b/Assets/UI_Extension/Scripts/Animation/Tween/TweenModule_Alpha.cs new file mode 100644 index 0000000..55ff647 --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/TweenModule_Alpha.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +namespace TweenAnimation +{ + [Serializable] + public class TweenAlpha : TweenModule + { + public Graphic target; + public float from; + public float to; + + protected override void SetValue(float time) + { + float t = time / duration; + float alpha = Mathf.Lerp(from, to, t); + if (target != null) + { + Color c = target.color; + c.a = alpha; + target.color = c; + } + } + +#if UNITY_EDITOR + public override string name { get { return "Alpha"; } } + +#endif + + } +} \ No newline at end of file -- cgit v1.1-26-g67d0