48 lines
1.1 KiB
C#
48 lines
1.1 KiB
C#
using UnityEngine;
|
|
|
|
public class FlowIntroStampMotion : MonoBehaviour
|
|
{
|
|
private const float Duration = 0.18f;
|
|
|
|
private RectTransform rectTransform;
|
|
private Vector3 baseScale = Vector3.one;
|
|
private float startTime = -1f;
|
|
|
|
private void Awake()
|
|
{
|
|
rectTransform = GetComponent<RectTransform>();
|
|
if(rectTransform != null)
|
|
{
|
|
baseScale = rectTransform.localScale;
|
|
}
|
|
}
|
|
|
|
public void Play()
|
|
{
|
|
if(rectTransform == null)
|
|
{
|
|
rectTransform = GetComponent<RectTransform>();
|
|
}
|
|
|
|
if(rectTransform != null)
|
|
{
|
|
baseScale = Vector3.one;
|
|
rectTransform.localScale = baseScale * 1.42f;
|
|
}
|
|
|
|
startTime = Time.unscaledTime;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if(rectTransform == null || startTime < 0f)
|
|
{
|
|
return;
|
|
}
|
|
|
|
float t = Mathf.Clamp01((Time.unscaledTime - startTime) / Duration);
|
|
float scale = Mathf.Lerp(1.42f, 1f, 1f - Mathf.Pow(1f - t, 3f));
|
|
rectTransform.localScale = baseScale * scale;
|
|
}
|
|
}
|