SHADE_Y3/Assets/Scripts/UI/SC_ScaleBounce.cs

59 lines
1.3 KiB
C#

using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting.UI
{
public class ScaleBounce : Script
{
[NonSerialized]
private TweenThread thread;
public float minScale = 1.0f;
public float maxScale = 1.2f;
public float duration = 1.0f;
private Vector3 defaultScale;
public bool isActive = false;
private bool lastActive = false;
protected override void start()
{
thread = TweenManager.CreateTweenThread(duration, minScale, maxScale, EASING_METHOD.EASE_IN_SINE);
Transform trans = GetComponent<Transform>();
if(trans != null)
{
defaultScale = trans.LocalScale;
}
}
protected override void update()
{
if(isActive != lastActive && isActive == true)
{
thread.Reset();
}
lastActive = isActive;
Transform trans = GetComponent<Transform>();
if(trans != null && isActive)
{
trans.LocalScale = defaultScale * thread.GetValue();
}
if(thread.IsCompleted())
{
thread.ResetInvert();
}
}
}
}