Override or listen for editor Play button

Just wondering if it is possible to create an editor script to listen when the user has clicked on the Play button in the editor. I’d like to make a script which over rides this - don’t play, instead do another action first, and then play the scene.

Any thoughts?

I think your best bet would be to have an editor script listen to EditorApplication.isPlayingOrWillChangePlaymode … actually, take a look at EditorApplication-isCompiling, which seems like a Unity example to do exactly that.

In a last resort, perhaps EditorApplication.CallbackFunction would be of use.