Search Unity

Feedback Request - OnDestroy(applicationQuit)

Discussion in 'Editor & General Support' started by joshcamas, Aug 20, 2019.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    Hello!

    One feature I end up using over and over again is detecting whether the OnDestroy function is running when application is quitting:

    Code (CSharp):
    1. bool applicationQuitting;
    2.  
    3. private void OnApplicationQuit()
    4. {
    5.         applicationQuitting = true;
    6. }
    7.  
    8. private void OnDestroy()
    9. {
    10.         if(applicationQuitting)
    11.                 //do stuff
    12.         else
    13.                 //do other stuff
    14. }
    Now, this is fine, and not a big deal of course. But it would be *amazing* if this could be built in, assuming it could be optional since otherwise it would break old code XD
     
    Joe-Censored likes this.