using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

[ExecuteInEditMode()]
public class ProgressBar : MonoBehaviour
{
    public RectTransform bar;

    public void SetFill(int current, int max)
    {
        if (current > max)
            current = max;

        float fillAmount = (float)current / (float)max;

        if (float.IsNaN(fillAmount) || float.IsInfinity(fillAmount))
            fillAmount = 0;

        bar.localScale = new Vector3(fillAmount, 1.0f, 1.0f);
    }
}
