hellbound/Assets/Scripts/Core/CheatsHotkeys.cs

47 lines
956 B
C#
Raw Normal View History

2021-11-26 11:16:25 +03:00
using System;
using System.Collections.Generic;
using UnityEngine;
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();
}
}
}
}