I'm writing an editor addon and was wondering if there was any way I could tell when a node's owner is set so I can propagate that change to all its children as well?
Is there a way to detect when a node's owner is set?
- Edited
kitfox You can override virtual Object::_set()
to intercept property changes. The important thing is to return false from it so that normal property assignment is performed by the engine. Also note that in order for _set()
to be called, you need to use self.
or set()
when changing a property. It'll be called when changing properties from editor at runtime as well.
func _set(property, value):
if(property == "owner"):
print("PROPAGATING OWNER")
return false
func _ready():
self.owner = get_parent() # calls _set()
set("owner", get_parent()) # calls _set() as well
owner = get_parent() # doesn't call _set()