I already know how to use setters and getters on variables that I created. But how do I do this for a property / value for something that is inbuilt / already part of Node?
For example, if I have a tool-type scene in my project, how would I print its new coordinates every time I move it? Or (a concrete example from my project) how would I print the new value every time I change a VisibleOnScreenEnabler2D’s Node Path (enable_node_path)?
Godot doesn’t have such a feature, you can only check it every frame, or present another property, and use it instead. Just think about it, listening to every property is too expensive, however, we won’t care about every property change, and this is why we create signals when it is needed.
I’m not sure this is true. Godot must have such a feature otherwise how’d the IDE know a property changed? In fact it seems what I’m looking for is called _set. So using this:
func _set(property, value):
if property == "enable_node_path":
var target = get_node(value)
var N = target.name
print("Enable Node path name: ", N)
enable_node_path = value
return true
else:
print(property)
return true # or should this return false? Tried both but didn't notice any differences
I was able to detect that I’m editing the Node’s properties: