Add cutting progress bar
This commit is contained in:
parent
8194937cd8
commit
4ad7bf281c
8 changed files with 761 additions and 42 deletions
43
Assets/Scripts/ProgressBarUI.cs
Normal file
43
Assets/Scripts/ProgressBarUI.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ProgressBarUI : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private CuttingCounter cuttingCounter;
|
||||
[SerializeField] private Image barImage;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
cuttingCounter.OnProgressChange += CuttingCounter_OnProgressChange;
|
||||
|
||||
barImage.fillAmount = 0f;
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void CuttingCounter_OnProgressChange(object sender, CuttingCounter.OnProgressChangeEventsArgs e)
|
||||
{
|
||||
barImage.fillAmount = e.progressNormalized;
|
||||
|
||||
if (e.progressNormalized == 0f || e.progressNormalized == 1f) {
|
||||
Hide();
|
||||
} else
|
||||
{
|
||||
Show();
|
||||
}
|
||||
}
|
||||
|
||||
private void Show()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue