2026-04-28 왼쪽 손목에 포만감 배치

This commit is contained in:
2026-04-28 17:06:13 +09:00
parent 07360de42c
commit 5f44249b4a
10 changed files with 248 additions and 2 deletions

View File

@@ -0,0 +1,40 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using VRShopping.Player;
namespace VRShopping.UI
{
// 왼쪽 손목에 부착되는 허기 게이지 HUD.
// PlayerHunger.Instance에 자동 구독.
public class HungerHud : MonoBehaviour
{
[SerializeField] private Image _fillImage; // type=Filled 권장
[SerializeField] private TMP_Text _text; // 옵션, "80 / 100" 형식
[SerializeField] private PlayerHunger _bound;
private void Start()
{
_bound.OnHungerChanged += HandleChanged;
HandleChanged(_bound.Current, _bound.Max);
}
private void OnDestroy()
{
if (_bound != null)
{
_bound.OnHungerChanged -= HandleChanged;
_bound = null;
}
}
private void HandleChanged(float current, float max)
{
if (_fillImage != null && max > 0f)
_fillImage.fillAmount = Mathf.Clamp01(current / max);
if (_text != null)
_text.text = $"{Mathf.CeilToInt(current)} / {Mathf.CeilToInt(max)}";
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2f25be49768752d4596d4adf7819403d