45 lines
746 B
C#
45 lines
746 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UI_GetFishCounter : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Image fillCounter;
|
|
|
|
private CanvasGroup canvasGroup;
|
|
|
|
private void OnEnable()
|
|
{
|
|
canvasGroup = GetComponent<CanvasGroup>();
|
|
UpdateCounter(0f);
|
|
FPlayer.OnFishPicking += UpdateCounter;
|
|
FPlayer.OnFishPicked += Hide;
|
|
FishFightState.OnExit += Hide;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
FPlayer.OnFishPicking -= UpdateCounter;
|
|
FPlayer.OnFishPicked -= Hide;
|
|
FishFightState.OnExit -= Hide;
|
|
}
|
|
|
|
private void Hide()
|
|
{
|
|
UpdateCounter(0f);
|
|
}
|
|
|
|
private void UpdateCounter(float value)
|
|
{
|
|
if (value == 0f)
|
|
{
|
|
canvasGroup.alpha = 0f;
|
|
}
|
|
else
|
|
{
|
|
canvasGroup.alpha = 1f;
|
|
}
|
|
fillCounter.fillAmount = value;
|
|
}
|
|
}
|