feature: Added progress bar

This commit is contained in:
Gerard Gascón 2024-01-28 10:54:56 +01:00
parent 60fd82cff5
commit a4a6cccc6c
4 changed files with 67 additions and 8 deletions

View 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;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bbbaf5b51c023404885d2bbb502c3276
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: