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

31 lines
832 B
C#
Raw Normal View History

using UnityEngine;
using UnityEngine.UI;
namespace TKS.OutGame
{
/// <summary>그래픽 알파 핑퐁(선택 테두리 등 · Fable 제안서 §3-3 「α 0.6↔1.0 0.8 s」) — 시간 = 실시간(일시정지 무관).</summary>
public class UiPulse : MonoBehaviour
{
public float min = 0.6f;
public float max = 1f;
public float period = 0.8f;
Graphic g;
float baseA = 1f;
void Awake()
{
g = GetComponent<Graphic>();
if (g != null) baseA = g.color.a;
}
void Update()
{
if (g == null || period <= 0f) return;
float t = Mathf.PingPong(Time.unscaledTime / period, 1f);
var c = g.color;
c.a = baseA * Mathf.Lerp(min, max, t);
g.color = c;
}
}
}