I need to detect a node being freed from a scene without using exited_tree() or child_exited_tree(), because I'm doing some automation in a tool script, and want to be able to have some of that automation happen when a node is deleted. The problem with using exited_tree() is this goes off when I switch scenes in the editor. This removes data when I don't want it removed from a resource that is tracking it. I can't seem to think of a good solution. Yes, I could create a way of deleting the node that specifically emits another signal then deletes the node, but what if I forget to use it? Then I'll be left with bad data from my automation. I need to figure out a way to detect a node being freed at edit time.
Things I've tried:
- I tried using notifications, but I must not understand how they work. This could still be the solution I'm looking for, but I'm just doing it wrong. This is what I'll be focusing my next googling session on, though.
- I tried overriding _notification(what) and doing
if is_queued_for_deletion()which is a method in Object, but this did not work at all. - I'm looking into doing something with scene_tree, but I don't know what yet. Still trying to figure out which thing would be relevant here from that.
- I investigated the possibility of finding/overriding some editor function like with a plugin, but I don't want to have to mess with plugin for that. I will if I need to, though.
I'll update if I figure this out, but I'd be super grateful for any insights.