Programmer
Programmer

Reputation: 125455

Detect when Editor exit/closes

I am making an Editor plugin that communicates with a native plugin made with C++. I am required to notify the native plugin when Editor is about to be closed. I spent few hours on Unity's doc looking for an event or callback function that can be used to detect when Editor closes but I couldn't find one.

Usually, OnApplicationQuit, OnApplicationPause and OnApplicationFocus are used for something like this on standalone build but this is for the Editor so it wouldn't work

Does anyone know about any function or event to do this? If this there no built-in solution to do, is there a hack or some other ways to do this?

Upvotes: 4

Views: 2217

Answers (2)

Atheos
Atheos

Reputation: 21

now there is EditorApplication.quitting in unity 2018.2

UnityEditor.EditorApplication.quitting += OnQuitting;

private void OnQuitting()
{
    // do what you want to do when editor quit
}

Upvotes: 2

MX D
MX D

Reputation: 2485

There is no native way to detect the shutdown of the editor it self.

However, you possibly could hook up to the proccess itself and wait for the exited event as described in this answer.

But if possible you will want to do this on the c++ side itself instead.

C++, How to determine if a Windows Process is running?

Upvotes: 2

Related Questions