Search Unity

Use onApplicationquit in the headless version

Discussion in 'Getting Started' started by yumianhuli1, Jan 1, 2019.

  1. yumianhuli1

    yumianhuli1

    Joined:
    Mar 14, 2015
    Posts:
    78
    Hello! I Used onApplicationquit function in the headless version for sending a message,but When I kill unity's process, The message was not thrown from onApplicationquit(),So what unity api can I use for this situation?(Normal exit is OK!)
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,426
    You need to send a message prior to onApplicationQuit. How are users exiting the application? On a button click or similar? At that point, you send the message.
     
  3. yumianhuli1

    yumianhuli1

    Joined:
    Mar 14, 2015
    Posts:
    78
    hello,headless verion.The app killed by linux command kill pid,thank u!
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,379
    You won’t get on quit if you kill the process. Killing the process is a fairly extreme measure, and is normally only done in extreme circumstances. Like when the process locks into an infinite loop or otherwise goes insane.

    Normally you will simply want to send the process a signal to quit.
     
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    13,908
    Linux's kill command is a bit deceptive in its naming. A kill command that only specifies the process ID doesn't forcibly kill an application but rather sends a SIGTERM command which asks the process to close gracefully (which the process can ignore if it wants to).

    https://www.linode.com/docs/tools-reference/tools/use-killall-and-kill-to-stop-processes-on-linux/
     
    Kiwasi likes this.
  6. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    2,869
    @Ryiah is an inexhaustible resource on technical matters both useful and obscure.