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