SHADE_Y3/Assets/Scripts/UI/SC_SingleScaleBounce.cs

74 lines
1.4 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 SingleScaleBounce : Script
{
[NonSerialized]
TweenThread thread;
[NonSerialized]
Vector3 defaultScale;
public float durationUp = 0.15f;
public float durationDown = 0.3f;
public float scaleSize = 1.2f;
[NonSerialized]
private bool scaleUp = false;
private Transform trans;
protected override void awake()
{
trans = GetComponent<Transform>();
if (trans != null)
{
defaultScale = trans.LocalScale;
}
}
protected override void start()
{
if(thread != null)
thread = TweenManager.CreateTweenThread(0.0f, 1.0f, 1.0f, EASING_METHOD.EASE_IN_SINE);
}
protected override void update()
{
if (scaleUp)
{
if (thread != null && thread.IsCompleted())
{
scaleUp = false;
thread.duration = durationDown;
thread.ResetInvert();
}
}
if (trans && thread != null)
trans.LocalScale = defaultScale * thread.GetValue();
}
public void ScaleBounceOnce()
{
scaleUp = true;
if (thread != null)
{
thread.duration = durationUp;
thread.Reset(1.0f, scaleSize);
}
}
}
}