Intercept OnApplicationQuit?

Hi there, in our game we had a problem where players would accidentally quit the game by accidentally clicking the red X in the top right of the window instead of the in-game button they meant to. We solved it by intercepting OnApplicationQuit, calling Application.CancelQuit() and asking them if they were sure they actually wanted to quit. However, this caused a problem with Photon. It seems Photon is also listening for OnApplicationQuit and calling Disconnect() when it fires, so even if the player cancels the quit, they still disconnect from the Photon. What would be the best way to solve this issue?

My first thought was to move that script to the front of the execution order, but that doesn't seem to work. We are using the PhotonNetworking dll, we recently upgraded from the version where we had the raw code.

Comments

  • The best way to solve this would be to make the red button open the dialog if the user really wants to quit, instead of calling Quit, then canceling it to show the dialog.
    Alternatively modify PUN's code: Find any OnApplicationQuit in our source, rename it and call it when you finally quit the app through the dialog.
  • Sorry, but the "red X" I meant Window's native close button. I'll look into the PUN code itself then.
  • Ah, I see.
    The solution is the same though. You need to remove the Disconnect call from OnApplicationQuit and call that yourself when you're really done with the app.
  • I also have this issue. Rather than changing PUN code that will get overwritten with the next update, for now I just removed my game's exit confirmation and let it exit if the user hits the Windows X button.

    Devs, could you maybe add a flag in PUN that we could set to control this behavior?