36 lines
868 B
C#
36 lines
868 B
C#
using TMPro;
|
|
using UnityEngine;
|
|
using VRShopping.Player;
|
|
|
|
namespace VRShopping.UI
|
|
{
|
|
// 왼쪽 손목 허기 게이지 위에 부착되는 소지금 HUD.
|
|
// PlayerWallet.OnBudgetChanged에 자동 구독.
|
|
public class WalletHud : MonoBehaviour
|
|
{
|
|
[SerializeField] private TMP_Text _text;
|
|
[SerializeField] private PlayerWallet _bound;
|
|
|
|
private void Start()
|
|
{
|
|
_bound.OnBudgetChanged += HandleChanged;
|
|
HandleChanged(_bound.Budget);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (_bound != null)
|
|
{
|
|
_bound.OnBudgetChanged -= HandleChanged;
|
|
_bound = null;
|
|
}
|
|
}
|
|
|
|
private void HandleChanged(int current)
|
|
{
|
|
if (_text != null)
|
|
_text.text = $"₩ {current:N0}";
|
|
}
|
|
}
|
|
}
|