diff --git a/Assets/Scripts/AccountMenu/AccountHandler.cs b/Assets/Scripts/AccountMenu/AccountHandler.cs index 0a228be..458226c 100644 --- a/Assets/Scripts/AccountMenu/AccountHandler.cs +++ b/Assets/Scripts/AccountMenu/AccountHandler.cs @@ -1,4 +1,6 @@ using UnityEngine; +using UnityEngine.InputSystem; +using UnityEngine.SceneManagement; public class AccountHandler : MonoBehaviour { @@ -98,4 +100,14 @@ public class AccountHandler : MonoBehaviour } foreach (CustomColorObject customColorObject in FindObjectsByType(FindObjectsSortMode.None)) customColorObject.SetColor(); } + + async void Update() + { + if (Keyboard.current.escapeKey.wasPressedThisFrame) + { + if (accountChangePassword.gameObject.activeSelf || accountChangeUsername.gameObject.activeSelf || accountRefreshLogin.gameObject.activeSelf) SwitchPanel(0); + else if (accountLogin.gameObject.activeSelf || accountRegister.gameObject.activeSelf) SwitchPanel(1); + else await SceneManager.LoadSceneAsync("MainMenu"); + } + } } \ No newline at end of file diff --git a/Assets/Scripts/ChatroomMenu.cs b/Assets/Scripts/ChatroomMenu.cs index 31757c1..a20c989 100644 --- a/Assets/Scripts/ChatroomMenu.cs +++ b/Assets/Scripts/ChatroomMenu.cs @@ -8,7 +8,9 @@ using System.Threading.Tasks; using Newtonsoft.Json.Linq; using TMPro; using UnityEngine; +using UnityEngine.InputSystem; using UnityEngine.Networking; +using UnityEngine.SceneManagement; using UnityEngine.UI; public class ChatroomMenu : MonoBehaviour @@ -301,11 +303,18 @@ public class ChatroomMenu : MonoBehaviour statusRoutine = StartCoroutine(StatusRoutine()); } - void Update() + async void Update() { var max = content.GetComponent().sizeDelta.y; var current = content.transform.localPosition.y; downButton.gameObject.SetActive(Mathf.Abs(max - current) > 0.1f * max); + if (Keyboard.current.escapeKey.wasPressedThisFrame && FindFirstObjectByType() == null) + { + if (optionsPanel.activeSelf) optionsPanelExitButton.onClick.Invoke(); + else if (reportMessagePanel.activeSelf) reportMessagePanelExitButton.onClick.Invoke(); + else if (editMessagePanelCurrent != null) editMessagePanelCurrent.transform.GetChild(0).GetChild(0).GetComponent