23 lines
711 B
C#
23 lines
711 B
C#
using PrizeSystem;
|
|
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(CanvasGroup))]
|
|
public class PrizeErrorLabel : MonoBehaviour
|
|
{
|
|
private CanvasGroup _canvasGroup;
|
|
|
|
private bool ShouldDisplay => SettingsManager.GetBool(SettingKey.PRIZING) && SettingsManager.GetBool(SettingKey.DISPLAY_PRIZING_ERROR);
|
|
|
|
void Start()
|
|
{
|
|
_canvasGroup = GetComponent<CanvasGroup>();
|
|
|
|
UpdateView();
|
|
SettingsManager.OnSettingsChanged += UpdateView;
|
|
PrizeSystemManager.OnErrorStateChanged += UpdateView;
|
|
}
|
|
|
|
private void UpdateView() => UpdateView(PrizeSystemManager.ErrorState);
|
|
|
|
private void UpdateView(bool error) => _canvasGroup.alpha = ShouldDisplay && error ? 1 : 0;
|
|
} |