feat: 게임 일시정지 중에도 하트 충전 시간 흘러갈 수 있도록 적용

This commit is contained in:
aube.lee
2025-02-27 00:57:48 +09:00
parent c04f30a1af
commit 49ca624fa5
2 changed files with 14 additions and 3 deletions

View File

@@ -238,7 +238,7 @@ MonoBehaviour:
m_text: + 0
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 3116464c7616674448f2fb05b50bf91b, type: 2}
m_sharedMaterial: {fileID: -5364670637895760327, guid: 3116464c7616674448f2fb05b50bf91b, type: 2}
m_sharedMaterial: {fileID: 0}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []

View File

@@ -15,15 +15,26 @@ namespace TON
public TextMeshProUGUI timerText; // 하트 충전 타이머 UI
public GameObject overHeartText; // 하트 충전 타이머 UI
private float lastUpdateTime;
private void OnEnable()
{
lastUpdateTime = Time.realtimeSinceStartup;
UpdateHeartUI(); // 시작 시 UI 갱신
}
private void FixedUpdate()
private void Update()
{
// 실제 시간 기반으로 일정 간격마다 업데이트 (Time.Scale = 0 에 영향받지 않도록)
float currentTime = Time.realtimeSinceStartup;
float deltaTime = currentTime - lastUpdateTime;
// 1초마다 타이머 업데이트 (더 짧은 간격으로 설정 가능)
if (deltaTime >= 1.0f)
{
UpdateTimer();
lastUpdateTime = currentTime;
}
}
public void UpdateHeartUI()