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:
    92
    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

    Joined:
    May 2, 2017
    Posts:
    14,446
    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:
    92
    hello,headless verion.The app killed by linux command kill pid,thank u!
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    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:
    21,205
    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:
    3,512
    @Ryiah is an inexhaustible resource on technical matters both useful and obscure.