Created
October 23, 2024 19:54
-
-
Save Gnumaru/23700f091ce457005ad336849a9eb832 to your computer and use it in GitHub Desktop.
how to run some code right AFTER an object has been freed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Node | |
func _notification(what: int) -> void: | |
if what == Object.NOTIFICATION_PREDELETE: | |
# post_delete is a static method, thus it can be called deferredly even by dying objects. Beware that an object can be "saved" from a queue_free call by calling cancel_free, but a free call (instead of queue_free) should kill it imediatly without chance for survival | |
post_delete.call_deferred(get_instance_id(), get_path()) | |
static func post_delete(id: int, path: NodePath) -> void: | |
print("node with instance id %s and path %s was just deleted" % [id, path]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment