Files
Learning-UnityNGO/Assets/CONTENT/FEATURES/DEV-TEST/Scripts/UI/PlayerHealthUIController.cs
T
2026-07-02 17:04:29 +03:00

27 lines
607 B
C#

using UnityEngine;
public class PlayerHealthUIController : MonoBehaviour
{
[SerializeField] private PlayerHealthView view;
private PlayerHealth playerHealth;
public void Bind(PlayerHealth _playerHealth)
{
playerHealth = _playerHealth;
playerHealth.HealthChanged += OnHealthChanged;
playerHealth.PushCurrentHealthValue();
}
public void OnHealthChanged(int _currentHealth, int _maxHealth)
{
view.UpdateHealth(_currentHealth, _maxHealth);
}
private void OnDestroy()
{
playerHealth.HealthChanged -= OnHealthChanged;
}
}