Files
2026-06-04 15:45:39 +03:00

60 lines
1.2 KiB
C#

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;
}
}