Files
2025TapTapGameJam/Assets/Script/Gameplay/UI/PlayerHpViewer.cs

32 lines
694 B
C#
Raw Normal View History

2025-10-15 21:31:13 +08:00
using System;
using Core;
using Gameplay.Player;
using UnityEngine;
using UnityEngine.UI;
namespace UI
{
public class PlayerHpViewer : UIBase
{
private PlayerController _playerController;
public Text hpText;
private void Awake()
2025-10-15 21:31:13 +08:00
{
ControllerLocator.Instance.TryGetWait<PlayerController>(OnGet);
2025-10-15 21:31:13 +08:00
}
private void Update()
{
if (_playerController != null)
{
hpText.text = "HP: " + _playerController.CurrentHealth;
}
}
private void OnGet(PlayerController playerController)
{
_playerController = playerController;
}
}
}