You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
485 B
C#
28 lines
485 B
C#
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace Projectiles.UI
|
|
{
|
|
public class UIHealth : UIBehaviour
|
|
{
|
|
// PRIVATE MEMBERS
|
|
|
|
[SerializeField]
|
|
private TextMeshProUGUI _healthValue;
|
|
|
|
private int _lastValue = -1;
|
|
|
|
// PUBLIC METHODS
|
|
|
|
public void UpdateHealth(Health health)
|
|
{
|
|
int currentHealth = Mathf.RoundToInt(health.CurrentHealth);
|
|
if (currentHealth == _lastValue)
|
|
return;
|
|
|
|
_healthValue.text = currentHealth.ToString();
|
|
_lastValue = currentHealth;
|
|
}
|
|
}
|
|
}
|