36 lines
855 B
C#
36 lines
855 B
C#
using UnityEngine;
|
|
#if ENABLE_INPUT_SYSTEM
|
|
using UnityEngine.InputSystem;
|
|
#endif
|
|
|
|
namespace UI.PanelStack
|
|
{
|
|
public class UIPanelStackInput : MonoBehaviour
|
|
{
|
|
[SerializeField] private bool enabledInput = true;
|
|
|
|
private void Update()
|
|
{
|
|
if (!enabledInput) { return; }
|
|
if (UIPanelStack.Instance == null) { return; }
|
|
|
|
if (IsEscapePressed())
|
|
{
|
|
if (!UIPanelStack.Instance.CloseTop())
|
|
{
|
|
UIPanelStack.Instance.TryOpenOnEscapeWhenEmpty();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool IsEscapePressed()
|
|
{
|
|
#if ENABLE_INPUT_SYSTEM
|
|
return Keyboard.current != null && Keyboard.current.escapeKey.wasPressedThisFrame;
|
|
#else
|
|
return Input.GetKeyDown(KeyCode.Escape);
|
|
#endif
|
|
}
|
|
}
|
|
}
|