using System.Collections; using System.Collections.Generic; using TMPro; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; public class PrizeChecker : MonoBehaviour { [SerializeField] bool needToDisplay = false; public TextMeshProUGUI label; private void Start() { InvokeRepeating("checkPrize", 0, 5); StartCoroutine(UpdateLabelVisibility()); } private void Update() { if (needToDisplay) { Color c = label.color; c.a = 0.2f + Mathf.PingPong(Time.time * 0.6f, 0.8f); label.color = c; } } void checkPrize() { bool prizesAvailable = PlayerPrefs.GetInt(KeyVault.PRIZES_AVAILABLE, 0) > 0; needToDisplay = !prizesAvailable; if (!SettingsManager.GetBool("DisplayNoPrizes", false)) { needToDisplay = false; } } IEnumerator UpdateLabelVisibility() { while (true) { float targetAlpha = needToDisplay ? 1 : 0; Color currentColor = label.color; Color targetColor = currentColor; targetColor.a = targetAlpha; while (targetColor != currentColor) { currentColor = Vector4.MoveTowards(currentColor, targetColor, Time.deltaTime); label.color = currentColor; yield return null; } yield return new WaitForSeconds(3); } } }