- Home /
GUILayout.Button jitters on Application.Quit (mobile)
We have a mobile game (Android) using Unity's GUI. One of the buttons on our main menu is a Quit button that should close the application.
void OnGUI()
{
if(GUILayout.Button("Quit", GUI.skin.FindStyle("button")))
Application.Quit();
}
void Update()
{
if(Input.GetKeyUp(KeyCode.Escape))
Application.Quit();
}
The problem is that when the Quit button is pressed, the button flickers or jitters between the active/focused/hover color and the normal color while the application quits. I've only been able to reproduce on mobile. This also happens if you touch and hold the button, then press the device Back button and quit from Update().
I doubt this is the problem, but you should avoid using and kind of Find function in Update or OnGUI. Do your Find in Start and keep it in a private variable.
Your answer
Follow this Question
Related Questions
Problem in setting GUI Button for mobile device 1 Answer
How do I make a "move pad" on the screen? (Mobile) 1 Answer
android and ios - phantom UGUI Button click when loading new scene w/ finger already down 1 Answer
Drag and Drop button on Mobile (Messenger style) 0 Answers
Why this simple code doesnt work? 0 Answers