using TMPro; using UnityEngine; namespace DepthsOfGreed.HandbookUI { public sealed class GeneralFeedbackController : MonoBehaviour { [SerializeField] private RectTransform panel; [SerializeField] private TMP_Text message; private bool error; private float until; public void Initialize(RectTransform book, TMP_FontAsset font) { if (font) message.font = font; panel.gameObject.SetActive(false); } public void ShowControls(string text) { error = false; until = 0; message.text = text; panel.gameObject.SetActive(true); } public void ShowError(string text, bool bookOpen) { error = true; until = Time.unscaledTime + 3; message.text = text; panel.gameObject.SetActive(true); } public void HideControls() { if (!error) panel.gameObject.SetActive(false); } private void Update() { if (error && Time.unscaledTime > until) { panel.gameObject.SetActive(false); error = false; } } } }