24 lines
749 B
C#
24 lines
749 B
C#
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
|
||
|
|
public class ImageAlphaPingPong : MonoBehaviour
|
||
|
|
{
|
||
|
|
public float speed = 1f; // 알파값 변화 속도
|
||
|
|
public float minAlpha = 0.2f; // 최소 알파값
|
||
|
|
public float maxAlpha = 1f; // 최대 알파값
|
||
|
|
|
||
|
|
Image m_img;
|
||
|
|
|
||
|
|
private void Update()
|
||
|
|
{
|
||
|
|
if (DSUtil.CheckNull(m_img))
|
||
|
|
m_img = GetComponent<Image>();
|
||
|
|
// Mathf.PingPong을 사용하여 0과 1 사이에서 반복되는 값 생성
|
||
|
|
float alpha = Mathf.Lerp(minAlpha, maxAlpha, Mathf.PingPong(Time.time * speed, 1));
|
||
|
|
|
||
|
|
// 텍스트 색상에서 알파 채널만 업데이트
|
||
|
|
Color color = m_img.color;
|
||
|
|
color.a = alpha;
|
||
|
|
m_img.color = color;
|
||
|
|
}
|
||
|
|
}
|