using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ResourceHealthBar : MonoBehaviour { private Slider slider; private float currentHealth, maxHealth; public GameObject globalState; void Awake() { slider = GetComponent(); } private void Update() { currentHealth = globalState.GetComponent().resourceHealth; maxHealth = globalState.GetComponent().resourceMaxHealth; float fillValue = currentHealth/maxHealth; slider.value = fillValue; // healthCounter.text = currentHealth+"/"+maxHealth; } }