using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UIProgressBar : MonoBehaviour { [SerializeField] private Image _progressImage; private float _clampedValue = 0; public float ClampedValue { get => _clampedValue; set { _progressImage.fillAmount = value; } } [SerializeField] private float _maxValue; [SerializeField] [Range(0,1)] private float _startValue; private void Start() { ClampedValue = Mathf.Clamp01(_startValue); } public void ChangeValue(int value) { ClampedValue = Mathf.Clamp01(value / _maxValue); } public void ChangeValue(float value) { ClampedValue = Mathf.Clamp01(value / _maxValue); } }