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

45 lines
1.3 KiB
C#

using UnityEngine;
namespace TKS.OutGame
{
/// <summary>
/// 등장 튀김(Fable 제안서 §4-2 「별 0.15 s 간격 scale 1.4→1」) — 켜질 때마다 delay 뒤 from → 1 · 시간 = 실시간(일시정지 무관).
/// 움직이는 동안 매 프레임 바뀌므로 Frame 캔버스로 분리(부모가 이미 Frame 층이면 그 층 · PD 2026-11-10 캔버스 분할) · 끝나면 쓰기를 멈춘다.
/// </summary>
public class UiPop : MonoBehaviour
{
public float delay;
public float from = 1.4f;
public float duration = 0.18f;
float t0;
bool done;
void Awake()
{
UiLayer.Isolate(gameObject);
}
void OnEnable()
{
Play();
}
public void Play()
{
t0 = Time.unscaledTime + delay;
done = false;
transform.localScale = Vector3.zero;
}
void Update()
{
if (done) return;
float t = Time.unscaledTime - t0;
if (t < 0f) return; // 기다리는 동안 = Play 가 둔 0 그대로
float k = duration > 0f ? Mathf.Clamp01(t / duration) : 1f;
transform.localScale = Vector3.one * Mathf.Lerp(from, 1f, 1f - (1f - k) * (1f - k));
done = k >= 1f;
}
}
}