rabidus-test/Assets/UIProgressBar.cs

44 lines
824 B
C#
Raw Normal View History

2023-09-04 12:48:24 +03:00
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);
}
}