2023-02-27 07:32:26 +08:00
|
|
|
|
using SHADE;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SHADE_Scripting.UI
|
|
|
|
|
{
|
2023-03-31 15:02:31 +08:00
|
|
|
|
public class ScaleBounce : Script
|
|
|
|
|
{
|
|
|
|
|
[NonSerialized]
|
|
|
|
|
private TweenThread thread;
|
2023-02-27 07:32:26 +08:00
|
|
|
|
|
2023-03-31 15:02:31 +08:00
|
|
|
|
public float minScale = 1.0f;
|
|
|
|
|
public float maxScale = 1.2f;
|
|
|
|
|
public float duration = 1.0f;
|
2023-02-27 07:32:26 +08:00
|
|
|
|
|
2023-03-31 15:02:31 +08:00
|
|
|
|
private Vector3 defaultScale;
|
2023-02-27 07:32:26 +08:00
|
|
|
|
|
|
|
|
|
|
2023-03-31 15:02:31 +08:00
|
|
|
|
public bool isActive = false;
|
|
|
|
|
|
|
|
|
|
private bool lastActive = false;
|
2023-03-31 14:50:25 +08:00
|
|
|
|
|
2023-02-27 07:32:26 +08:00
|
|
|
|
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()
|
|
|
|
|
{
|
2023-04-01 16:31:23 +08:00
|
|
|
|
if (thread == null)
|
|
|
|
|
return;
|
2023-03-31 15:02:31 +08:00
|
|
|
|
if(isActive != lastActive && isActive == true)
|
|
|
|
|
{
|
|
|
|
|
thread.Reset();
|
|
|
|
|
}
|
|
|
|
|
lastActive = isActive;
|
|
|
|
|
|
2023-02-27 07:32:26 +08:00
|
|
|
|
Transform trans = GetComponent<Transform>();
|
2023-03-31 14:50:25 +08:00
|
|
|
|
if(trans != null && isActive)
|
2023-02-27 07:32:26 +08:00
|
|
|
|
{
|
|
|
|
|
trans.LocalScale = defaultScale * thread.GetValue();
|
|
|
|
|
}
|
|
|
|
|
if(thread.IsCompleted())
|
|
|
|
|
{
|
|
|
|
|
thread.ResetInvert();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|