Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Dec 15, 2014 at 03:01 PM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
5
Question by Ony · Jun 25, 2010 at 04:37 AM · applicationquitexit

onExit, onQuit, or anything like that?

Is there any way to always have a function run on application exit?

I was just about to put something that works when I call Application.Quit() from in the game when the player clicks to quit, but then...

I realized I don't know how to trap whether they are using the exit button on a windowed screen and not one of my own exit buttons from in the game.

Anyone know how to trap an exit to do something right before it quits out (set a registry variable for instance), no matter how the user quits out?

Comment
Add comment · Show 2
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 qJake · Jun 25, 2010 at 04:55 AM 2
Share

Just FYI, you can never handle when the user kills the process via the Task $$anonymous$$anager (or via Force Quit on OSX). The "OnApplicationQuit" and "CancelQuit" events/properties are definitely what you're looking for, though.

avatar image UnityUse · Dec 15, 2014 at 02:04 PM 0
Share

What about EditorApplication.OnExit, is that too much to ask?

2 Replies

  • Sort: 
avatar image
8
Best Answer

Answer by Tetrad · Jun 25, 2010 at 04:46 AM

http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnApplicationQuit.html

Comment
Add comment · Show 4 · 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 Ony · Jun 29, 2010 at 12:33 AM 0
Share

both of you guys basically had helpful answers but I can only tag one as the right one so I did the first one submitted. Thanks for the help!

avatar image VolureDarkAngel · Oct 04, 2013 at 04:47 PM 2
Share

that is funny. because I see the comment, but i also see two answers tagged as correct...

avatar image clunk47 · Feb 21, 2014 at 09:59 PM 0
Share

what an odd bug lol

avatar image yuriki · Jun 26, 2016 at 01:28 PM 0
Share

Right link https://docs.unity3d.com/ScriptReference/$$anonymous$$onoBehaviour.OnApplicationQuit.html

avatar image
6

Answer by dhendrix · Jun 25, 2010 at 04:45 AM

I think you want something like this.

Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Will Unity wait the method to finish before the application is closed/quit/stop? 1 Answer

Application.Quit() not working 2 Answers

Delay quitting and finish some coroutines 1 Answer

Unity will not open(Linux) 0 Answers

How to Exit Application in Android on Back Button 3 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