Capture close event on Windows

Hi,

First of all, when Monobehaviour.OnApplicationQuit() is called, all Monobehaviour.OnDestroy() has already been executed, so it’s not a solution for me as Application.Quit() is invoked too late. Also, this problem I’m facing, for now, only concerns Windows platform.

When the user hits the close button on windowed mode or ALT+F4 in any mode, a message is sent to the application. I’d like to ask the user if he really wants to quit and weather or not to save changes made to the environment.

For other platforms, either Mac or webplayer, similar solutions will be considered if needed. For now, the first depploy is for windows and we need a very specific solution.

Thanks in advance for any help

Maybe the problem lies with me and I’m not enough experienced with .NET by itself, however, for the sake of future readers, here’s what happened:

After importing a lot of “user32.dll” functions into C# following some quite good tutorials (I’ll paste the links later) and with a lot of help from some friends, we were able to provide a new function (method, whatever makes you confortable) to handle signals for the application.

Downside is, no clicking or dragging relative to the new UGUI worked whatsoever. Therefore, after managing to grab the WM_CLOSE event, we could not redirect other events to unity’s automatically built handler. At this point, changing the window event handler became to tiresome and bug-prone to consider…