using System.Collections; using UnityEngine; using UnityEngine.UI; public class HintManager : MonoBehaviour { public static HintManager Instance { get; private set; } public GameObject hintPanel; public Text hintText; private Coroutine hideRoutine; private void Awake() { if (Instance != null && Instance != this) { Destroy(gameObject); return; } Instance = this; HideHint(); } public void ShowHint(string text, float duration) { if (hintPanel == null || hintText == null) { return; } // Restarting the timer lets stronger narrative hints replace short interaction prompts. hintText.text = text; hintPanel.SetActive(true); if (hideRoutine != null) { StopCoroutine(hideRoutine); } hideRoutine = StartCoroutine(HideAfterDelay(duration)); } public void HideHint() { if (hintPanel != null) { hintPanel.SetActive(false); } } private IEnumerator HideAfterDelay(float delay) { yield return new WaitForSeconds(delay); HideHint(); hideRoutine = null; } }