- Home /
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?
Answer by steo · Jan 15, 2017 at 03:50 PM
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.
Answer by Adam-Mechtley · Jan 14, 2017 at 02:00 PM
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.
Your answer
Follow this Question
Related Questions
How to get the currently selected object in the project window only 2 Answers
How can i add a second camera that will be showing only specific gameobject in game window ? 1 Answer
PrefabUtility - Check if Changes have been made to Prefab? 3 Answers
OnSceneGUI event Use() ates too much :) 1 Answer
How to get Event.KeyboardEvent from non-focused EditorWindow? 0 Answers