50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace RND
|
|
{
|
|
|
|
public class CheatsHotkeys : MonoBehaviour
|
|
{
|
|
private readonly List<Window> _windows = new List<Window>(10);
|
|
|
|
private void Awake()
|
|
{
|
|
#if !UNITY_EDITOR
|
|
Destroy(this);
|
|
#endif
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
ToggleUI();
|
|
}
|
|
|
|
private void ToggleUI()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Space))
|
|
{
|
|
bool hasClosedWindows = _windows.Count > 0;
|
|
|
|
if (UI.GetVisibleStack().Count > 0)
|
|
_windows.Clear();
|
|
|
|
if (hasClosedWindows)
|
|
{
|
|
foreach (var window in _windows)
|
|
window.Show();
|
|
|
|
_windows.Clear();
|
|
}
|
|
else
|
|
{
|
|
_windows.AddRange(UI.GetVisibleStack());
|
|
|
|
foreach (Window window in _windows)
|
|
window.Hide();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|