Initial Unity project commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user