using System.Collections.Generic; using UnityEngine; public static class GameUIState { private static readonly HashSet OpenPanels = new HashSet(); public static bool IsAnyBlockingUIOpen => OpenPanels.Count > 0; public static bool IsPanelOpen(string panelKey) { return OpenPanels.Contains(panelKey); } public static bool HasBlockingUIExcept(string panelKey) { var ignoredCount = OpenPanels.Contains(panelKey) ? 1 : 0; return OpenPanels.Count > ignoredCount; } public static void SetPanelOpen(string panelKey, bool isOpen) { if (string.IsNullOrEmpty(panelKey)) { return; } if (isOpen) { OpenPanels.Add(panelKey); } else { OpenPanels.Remove(panelKey); } SyncCursorAndTime(); } public static void Reset() { OpenPanels.Clear(); SyncCursorAndTime(); } public static void SyncCursorAndTime() { var shouldPause = IsAnyBlockingUIOpen; Time.timeScale = shouldPause ? 0f : 1f; Cursor.visible = shouldPause; Cursor.lockState = shouldPause ? CursorLockMode.None : CursorLockMode.Locked; } }