Similarly to how OnApplicationQuit runs on game being stopped in the editor, how do I detect when the Unity Editor quits?
You can use the [ExecuteInEditMode]
attribute to make unity call the OnDestroy()
message
using UnityEngine;
[ExecuteInEditMode]
public class YourClass : MonoBehaviour
{
void OnDestroy() //called when unity editor is closing
{
//stuff here
}
}