OwlyOwl

healthbar

May 25th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.39 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class HealthBar : MonoBehaviour
  7. {
  8.  
  9.     [SerializeField] Slider slider;
  10.     [SerializeField] Image fill;
  11.  
  12.     public void SetMaxHealth(int health)
  13.     {
  14.         slider.maxValue = health;
  15.         slider.value = health;
  16.     }
  17.  
  18.     public void SetHealth(int health)
  19.     {
  20.         slider.value = health;
  21.     }
  22.  
  23. }
Add Comment
Please, Sign In to add comment