using System.Collections; using UnityEngine; using TMPro; namespace BaseGames.Tutorial { /// /// 教程提示 UI 组件(架构 21_LiquidPuzzleModule §17)。 /// 负责显示/隐藏提示面板和文字;duration ≤ 0 时不自动消隐。 /// public class TutorialHintUI : MonoBehaviour { [SerializeField] private GameObject _panel; [SerializeField] private TMP_Text _label; [SerializeField] private float _fadeSpeed = 4f; private Coroutine _autoHideCoroutine; // ── 公共 API ────────────────────────────────────────────────────── /// 显示提示文字。duration ≤ 0 时不自动消隐。 public void Show(string text, float duration = 0f) { if (_panel != null) _panel.SetActive(true); if (_label != null) _label.text = text; if (_autoHideCoroutine != null) StopCoroutine(_autoHideCoroutine); if (duration > 0f) _autoHideCoroutine = StartCoroutine(AutoHideRoutine(duration)); } /// 立即隐藏提示面板。 public void Hide() { if (_autoHideCoroutine != null) { StopCoroutine(_autoHideCoroutine); _autoHideCoroutine = null; } if (_panel != null) _panel.SetActive(false); } // ── 内部 ────────────────────────────────────────────────────────── private IEnumerator AutoHideRoutine(float duration) { yield return new WaitForSeconds(duration); Hide(); _autoHideCoroutine = null; } } }