using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; public class ProgressBar : MonoBehaviour { // Start is called before the first frame update public Image progressBarBody; public Image progressBarBackground; public int setValue=0; private float step; private float height; void Start() { step = progressBarBody.GetComponent().rect.width / 100; height = progressBarBody.GetComponent().rect.height; } // Update is called once per frame void Update() { float width = step * setValue; progressBarBody.GetComponent().sizeDelta = new Vector2(width, height); progressBarBody.GetComponent().anchoredPosition = new Vector2(width/2,0); } }