Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- private void Awake()
- {
- slider = GetComponent<Slider>();
- }
- private void Update()
- {
- currentHealth = globalState.GetComponent<GlobalState>().resourceHealth;
- maxHealth = globalState.GetComponent<GlobalState>().resourceMaxHealth;
- float fillValue = currentHealth / maxHealth;
- slider.value = fillValue;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement