- Home /
Remove Quit Functionality from Mac/PC Build
Basically I have developed fullscreen pc/mac game. I want to remove default quit game functionality from my game.
Cmd + Q -> Mac Alt + F4 -> PC
These are two way for quiting for game forcefully. I want to stop this. Pleaes give me some suggestion for this.
EDIT:
void Update ()
{
// if (Input.GetKeyDown (KeyCode.Q) && Input.GetKeyDown (KeyCode.LeftCommand)) {
// isIgnoreQuit = true;
//// Application.CancelQuit ();
// }
// app quit functionality
if (!isQuit && Input.GetKey (KeyCode.Q) && Input.GetKey (KeyCode.E) && Input.GetKey (KeyCode.T) && Input.GetKey (KeyCode.U) && ((Input.GetKey (KeyCode.Keypad0) && Input.GetKey (KeyCode.Keypad9))
|| (Input.GetKey (KeyCode.Alpha0) && Input.GetKey (KeyCode.Alpha9)))) {
isQuit = true;
Application.Quit ();
}
}
// void OnApplicationQuit ()
// {
// if (isIgnoreQuit)
// Application.CancelQuit ();
//
// isIgnoreQuit = false;
// }
In above code, keypress event don't have any effect.
Answer by tanoshimi · Dec 01, 2016 at 04:14 PM
Untested, but I imagine
void OnApplicationQuit() {
Application.CancelQuit();
}
might do it.
but through button click I want to quit, just not by key press...
Then add some test:
void OnApplicationQuit() {
if(!quittingAllowed)
Application.CancelQuit();
}
And only set quittingAllowed=true when you want
Application.CancelQuit(); you can't able to quit app at all.
I want to put condition for Cmd + Q and Alt + F4 press, but by managing flag its not working.
then have your button also change a boolean value. if the boolean is false cancel the quit, otherwise when true (from getting set true by the button click) the application will continue to quit.
@Joshua$$anonymous$$c$$anonymous$$enzie, yes I can put reverse condition.
Rather than setting watch on keys, I can place flag setting for button click. At time of Application.Quit().....
Your answer
Follow this Question
Related Questions
Mac build not run on other users mac 1 Answer
Open project from MAC at PC 2 Answers
project management of a Multi platform asset 1 Answer
Mac os x development to PC 1 Answer
Can you transfer a Unity Pro license from a Mac to a PC? 0 Answers