using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.InputSystem; #if UNITY_EDITOR using UnityEditor; #endif public class QuitGame : MonoBehaviour { public Image QuitGraphic; private float HoldTime = 0.0f; public void Quit() { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else Application.Quit(); #endif } private void Update() { foreach (var controller in Gamepad.all) { if (controller.squareButton.IsPressed()) { HoldTime += Time.deltaTime; QuitGraphic.fillAmount = HoldTime/2f; if (HoldTime > 2f) Quit(); return; } } // Debug.Log("C# even managed to fuck up return statements"); QuitGraphic.fillAmount = 1f; HoldTime = 0.0f; } }