fix: 아이콘이 정상적으로 출력되지 않는 오류 수정

This commit is contained in:
aube.lee
2025-03-10 01:50:20 +09:00
parent d5d56ca8cc
commit 9e925a6c86
19 changed files with 67 additions and 59 deletions

View File

@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace TON
{
public class PotionButtonItem : MonoBehaviour
{
[SerializeField] private TextMeshProUGUI coolTimeText;
[SerializeField] private Image coolTimeDimd;
private float currentCoolDown = 0f;
private float potionCoolDown = 5f;
public void SetCurrentCoolDown()
{
currentCoolDown = potionCoolDown; // 쿨타임 시작
}
private void Update()
{
if (currentCoolDown == 0f)
return;
UpdateCooldownUI();
}
private void UpdateCooldownUI()
{
if (coolTimeText == null || coolTimeDimd == null)
{
return; // UI가 삭제되었으면 업데이트 중단
}
currentCoolDown -= Time.deltaTime;
currentCoolDown = Mathf.Max(0, currentCoolDown);
coolTimeText.gameObject.SetActive(currentCoolDown > 0); // 남은 쿨타임이 있을 때만 표시
if (coolTimeText.IsActive())
{
coolTimeText.text = $"{currentCoolDown: 0}s"; // 정수 초단위 표시
coolTimeDimd.fillAmount = currentCoolDown / potionCoolDown; // 1 → 0 으로 감소
}
}
}
}