Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by siddharth3322 · Dec 01, 2016 at 03:34 PM · unity5macpckeycodequit

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by tanoshimi · Dec 01, 2016 at 04:14 PM

Untested, but I imagine

 void OnApplicationQuit() {
   Application.CancelQuit();
 }

might do it.

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image siddharth3322 · Dec 01, 2016 at 05:38 PM 0
Share

but through button click I want to quit, just not by key press...

avatar image tanoshimi siddharth3322 · Dec 01, 2016 at 06:02 PM 0
Share

Then add some test:

 void OnApplicationQuit() {
   if(!quittingAllowed)
    Application.CancelQuit();

}

And only set quittingAllowed=true when you want

avatar image siddharth3322 tanoshimi · Dec 01, 2016 at 06:06 PM 0
Share

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.

avatar image JoshuaMcKenzie siddharth3322 · Dec 01, 2016 at 06:08 PM 1
Share

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.

avatar image siddharth3322 JoshuaMcKenzie · Dec 01, 2016 at 06:11 PM 0
Share

@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().....

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

62 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges