ThreeKingdomsSlingshot/Assets/Scripts/OutGame/UI/UiPop.cs

37 lines
997 B
C#

using UnityEngine;
namespace TKS.OutGame
{
/// <summary>등장 튀김(Fable 제안서 §4-2 「별 0.15 s 간격 scale 1.4→1」) — 켜질 때마다 delay 뒤 from → 1 · 시간 = 실시간(일시정지 무관).</summary>
public class UiPop : MonoBehaviour
{
public float delay;
public float from = 1.4f;
public float duration = 0.18f;
float t0;
void OnEnable()
{
Play();
}
public void Play()
{
t0 = Time.unscaledTime + delay;
transform.localScale = Vector3.zero;
}
void Update()
{
float t = Time.unscaledTime - t0;
if (t < 0f)
{
transform.localScale = Vector3.zero;
return;
}
float k = duration > 0f ? Mathf.Clamp01(t / duration) : 1f;
transform.localScale = Vector3.one * Mathf.Lerp(from, 1f, 1f - (1f - k) * (1f - k));
}
}
}