2019-04-08 16:14:50 +02:00

19 lines
428 B
C#

using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Serialization;
namespace UnityAtoms.Examples
{
public class HealthBar : MonoBehaviour
{
[FormerlySerializedAs("MaxHealth")]
[SerializeField]
private IntConstant _maxHealth = null;
public void HealthChanged(int health)
{
GetComponent<Image>().fillAmount = 1.0f * health / _maxHealth.Value;
}
}
}