Execute Script when removing competent while in edit mode.

I’m running into an issue where I’m trying get a script to run in the editor when the specific script (or the object its attached to) is removed/deleted from the scene. I am aware of the Execute in Edit mode tag but I can’t find any documentation stating that OnDestroy() works that way with it active and the personal testing I’ve done leads me to believe that it does not work that way. Is there another tag I can use, or is there a different event I could hook into to accomplish this?

I think there might be an OnValidate() that can do something, but not sure if it would be helpful in your case.

I was pretty sure OnDestroy() gets called too when you remove a component. That’s super-easy to test…

Welp, it does work I just forgot to enable the console window. My bad.

1 Like