Last active
January 8, 2022 08:54
-
-
Save k4sima/3b4007051d590072e0e25f5b7ad9edd6 to your computer and use it in GitHub Desktop.
Unity Application settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.InputSystem; | |
public class ApplicationSetting : MonoBehaviour | |
{ | |
[SerializeField] int FrameRate = 30; | |
[SerializeField] bool ESC_Quit = true; | |
void Start() | |
{ | |
Application.targetFrameRate = FrameRate; | |
} | |
void Update() | |
{ | |
if (ESC_Quit) | |
{ | |
var keyboard = Keyboard.current; | |
if (keyboard != null) | |
{ | |
if (keyboard.escapeKey.wasPressedThisFrame) | |
{ | |
Quit(); | |
} | |
} | |
} | |
} | |
void Quit() | |
{ | |
#if UNITY_EDITOR | |
UnityEditor.EditorApplication.isPlaying = false; | |
#else | |
Application.Quit(); | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment