SHADE_Y3/Assets/Scripts/UI/SC_FadeInOnActive.cs

40 lines
830 B
C#
Raw Normal View History

2023-03-21 14:40:30 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SHADE;
namespace SHADE_Scripting.UI
{
public class FadeInOnActive: Script
{
[NonSerialized]
TweenThread thread;
protected override void start()
{
thread = TweenManager.CreateTweenThread(0.5f, 0.0f, 1.0f, EASING_METHOD.LINEAR);
thread.SetResetOnInactive(GameObject);
}
protected override void update()
{
if(thread != null)
{
Renderable renderable = GetComponent<Renderable>();
if(renderable)
{
renderable.Material.SetProperty<float>("data.alpha", thread.GetValue());
}
}
}
}
}