Make it so you can press escape in any place in berrydash (almost any)

This commit is contained in:
2025-10-11 12:33:47 -07:00
parent 5496a0615d
commit 07b555bbc6
9 changed files with 84 additions and 1 deletions

View File

@@ -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<RectTransform>().sizeDelta.y;
var current = content.transform.localPosition.y;
downButton.gameObject.SetActive(Mathf.Abs(max - current) > 0.1f * max);
if (Keyboard.current.escapeKey.wasPressedThisFrame && FindFirstObjectByType<ProfileMenu>() == 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<Button>().onClick.Invoke();
else await SceneManager.LoadSceneAsync("MainMenu");
}
}
IEnumerator StatusRoutine()