sea-battle/Assets/Scripts/UI/Panels/InsufficientFundsPanel.cs

44 lines
1.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using UnityEngine;
/// <summary>
/// Панель "Пополните баланс" — показывается когда не хватает денег на игру.
/// Закрывается автоматически через autoHideDelay секунд.
///
/// Настройка в сцене:
/// - Добавь UIPanelId на этот же GameObject, id = "InsufficientFunds", layer = Overlay
/// - Настрой визуал (фон + TMP_Text с нужным текстом) прямо в редакторе
/// </summary>
public class InsufficientFundsPanel : MonoBehaviour
{
[SerializeField] private float autoHideDelay = 5f;
private Coroutine _hideCoroutine;
private void OnEnable()
{
// Каждый раз когда панель показывается — запускаем таймер автозакрытия
if (_hideCoroutine != null)
StopCoroutine(_hideCoroutine);
_hideCoroutine = StartCoroutine(AutoHide());
}
private void OnDisable()
{
if (_hideCoroutine != null)
{
StopCoroutine(_hideCoroutine);
_hideCoroutine = null;
}
}
private IEnumerator AutoHide()
{
yield return new WaitForSeconds(autoHideDelay);
gameObject.SetActive(false);
_hideCoroutine = null;
}
}