예산
This commit is contained in:
35
Assets/02_Scripts/UI/WalletHud.cs
Normal file
35
Assets/02_Scripts/UI/WalletHud.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/UI/WalletHud.cs.meta
Normal file
2
Assets/02_Scripts/UI/WalletHud.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59629d355895f5d48b2a59479440912f
|
||||
Reference in New Issue
Block a user