2026-04-20 카트 잡기
This commit is contained in:
34
Assets/02_Scripts/UI/GameTimerHud.cs
Normal file
34
Assets/02_Scripts/UI/GameTimerHud.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRShopping.UI
|
||||
{
|
||||
public class GameTimerHud : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameTimer _timer;
|
||||
[SerializeField] private TMP_Text _text;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (_timer == null) return;
|
||||
_timer.OnTick += HandleTick;
|
||||
HandleTick(_timer.Remaining);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (_timer == null) return;
|
||||
_timer.OnTick -= HandleTick;
|
||||
}
|
||||
|
||||
private void HandleTick(float remaining)
|
||||
{
|
||||
if (_text == null) return;
|
||||
|
||||
int total = Mathf.CeilToInt(remaining);
|
||||
int minutes = total / 60;
|
||||
int seconds = total % 60;
|
||||
_text.text = $"{minutes:00}:{seconds:00}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user