mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-24 17:17:47 -05:00
23 lines
506 B
C#
23 lines
506 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UniRx;
|
|
|
|
namespace UnityAtoms.Examples
|
|
{
|
|
public class HealthBarUniRx : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private IntConstant _maxHealth = null;
|
|
[SerializeField]
|
|
private IntVariable _health = null;
|
|
|
|
void Awake()
|
|
{
|
|
_health.ObserveChange().Subscribe(health =>
|
|
{
|
|
GetComponent<Image>().fillAmount = 1.0f * health / _maxHealth.Value;
|
|
});
|
|
}
|
|
}
|
|
}
|