Skip to content

Instantly share code, notes, and snippets.

@k4sima
Last active January 8, 2022 08:54
Show Gist options
  • Save k4sima/3b4007051d590072e0e25f5b7ad9edd6 to your computer and use it in GitHub Desktop.
Save k4sima/3b4007051d590072e0e25f5b7ad9edd6 to your computer and use it in GitHub Desktop.
Unity Application settings
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