Created
December 29, 2016 06:41
-
-
Save unity3dcollege/c07172a75f7654fcef8bc3bc851bc990 to your computer and use it in GitHub Desktop.
Updated HPBar.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
public class HPBar : MonoBehaviour | |
{ | |
private Slider slider; | |
private void Start() | |
{ | |
slider = GetComponentInChildren<Slider>(); | |
GetComponentInParent<Health>().OnHPPctChanged += HandleHPPctChanged; | |
} | |
private void HandleHPPctChanged(float pct) | |
{ | |
slider.value = pct; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment