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 HealthBar : MonoBehaviour {
- [Header("Input")]
- public float Progress = 0;
- public string Name;
- [Header("Settings")]
- public Image ProgressBar_Slot = null;
- public Image ProgressBar_Slider = null;
- public Text NameObj;
- public float maxProgress = 100;
- //Private
- private bool Working = false;
- void Start () {
- if(ProgressBar_Slot != null && ProgressBar_Slider != null)
- Working = true;
- }
- void Update () {
- if (Working) {
- NameObj.text = Name;
- Vector2 ProgressBar_Slot_Rect = new Vector2 (ProgressBar_Slot.rectTransform.sizeDelta.x, ProgressBar_Slot.rectTransform.sizeDelta.y);
- ProgressBar_Slider.rectTransform.rotation = ProgressBar_Slot.rectTransform.rotation;
- ProgressBar_Slider.rectTransform.position = ProgressBar_Slot.rectTransform.position;
- ProgressBar_Slider.rectTransform.sizeDelta = new Vector2 (((ProgressBar_Slot_Rect.x / maxProgress) * Progress), ProgressBar_Slot_Rect.y);
- } else {
- Debug.LogError ("(DLS_ProgressBar): You have left a Setting empty, the script will not work until you have filled it in.");
- this.enabled = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement