Files
2026-06-22 16:18:34 +02:00

50 lines
1.4 KiB
C#

using UnityEngine;
namespace Ashwild.UI
{
/// <summary>
/// Main-menu UI manager. Escape navigates the panel stack backwards; when already at the
/// default panel (the main menu) it opens a fallback panel instead — typically the
/// quit-confirmation. Put this on the menu canvas; gameplay uses <see cref="GameUIManager"/>.
/// </summary>
[DisallowMultipleComponent]
public class MenuUIManager : UIManager
{
#region Serialized Fields
[Header("Menu Escape")]
[Tooltip("Panel opened by Escape when already on the default (main menu) panel — e.g. ConfirmQuitPanel.")]
[SerializeField] private UIPanel escapeFallbackPanel;
#endregion
#region Escape Policy
/// <summary>
/// Escape: close the fallback if it is up, otherwise step back through the stack,
/// and finally open the fallback when sitting on the default panel.
/// </summary>
protected override void OnEscape()
{
if (Current == null) return;
if (escapeFallbackPanel != null && Current == escapeFallbackPanel)
{
Back();
return;
}
if (Current != defaultPanel)
{
Back();
return;
}
if (escapeFallbackPanel != null)
OpenPanel(escapeFallbackPanel);
}
#endregion
}
}