feature: Added progress bar
This commit is contained in:
parent
60fd82cff5
commit
a4a6cccc6c
4 changed files with 67 additions and 8 deletions
29
Assets/Scripts/Flow/ProgressBar.cs
Normal file
29
Assets/Scripts/Flow/ProgressBar.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Flow {
|
||||
public class ProgressBar : MonoBehaviour {
|
||||
[SerializeField] private Image bar;
|
||||
|
||||
private int _progressDone;
|
||||
[SerializeField, Min(0)] private int numberToWin = 10;
|
||||
|
||||
private void Awake() {
|
||||
UpdateFill();
|
||||
}
|
||||
|
||||
public void AddProgress() {
|
||||
_progressDone++;
|
||||
|
||||
if (_progressDone <= numberToWin) {
|
||||
UpdateFill();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateFill() {
|
||||
float fillPercentage = _progressDone / (float)numberToWin;
|
||||
bar.fillAmount = fillPercentage;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue