Get when Editor is closed for a docked extension

Hi All,

I need my addon to be able to save before the editor closes so that you don’t lose your data, however if the extension is docked neither OnDisable or OnDestroy will be called when you quit Unity. Does anyone know any solutions to this?

You can instantiate your MonoBehaviour marked as [ExecuteInEditMode] and hided by HideFlags.HideInHierarchy (and HideFlags.DontSave if need).

It’s OnDestroy() will be called when you quit Unity3D. Note that is will not be called on crashes.

Not ideal, but right now there is an internal UnityAction, EditorApplication.editorApplicationQuit which you could subscribe to via reflection. I’m currently looking into exposing more API points for editor callbacks, so this might end up public at some point.