Advertisement
Guest User

Untitled

a guest
Jan 8th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 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. [Header("Input")]
  9. public float Progress = 0;
  10. public string Name;
  11.  
  12. [Header("Settings")]
  13. public Image ProgressBar_Slot = null;
  14. public Image ProgressBar_Slider = null;
  15. public Text NameObj;
  16. public float maxProgress = 100;
  17.  
  18. //Private
  19. private bool Working = false;
  20.  
  21. void Start () {
  22. if(ProgressBar_Slot != null && ProgressBar_Slider != null)
  23. Working = true;
  24. }
  25.  
  26. void Update () {
  27. if (Working) {
  28. NameObj.text = Name;
  29. Vector2 ProgressBar_Slot_Rect = new Vector2 (ProgressBar_Slot.rectTransform.sizeDelta.x, ProgressBar_Slot.rectTransform.sizeDelta.y);
  30.  
  31. ProgressBar_Slider.rectTransform.rotation = ProgressBar_Slot.rectTransform.rotation;
  32. ProgressBar_Slider.rectTransform.position = ProgressBar_Slot.rectTransform.position;
  33. ProgressBar_Slider.rectTransform.sizeDelta = new Vector2 (((ProgressBar_Slot_Rect.x / maxProgress) * Progress), ProgressBar_Slot_Rect.y);
  34.  
  35. } else {
  36. Debug.LogError ("(DLS_ProgressBar): You have left a Setting empty, the script will not work until you have filled it in.");
  37. this.enabled = false;
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement