Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | monnef |
I know Resource
has changed
signal (which seems to be buggy in custom resources), but I am interested in prop change detection in Node
. I tried overriding _set
, but that didn’t pan out (I have to provide a return value signalling whether property exists, to add to the fire there is also no _set
in the parent class, so I would have to somewhere store all property names which defeats the point).
Real world example:
export(SpawnShape) var shape_type:= SpawnShape.POINT
export var shape_rectangle_size:= Vector2(1, 1)
export var shape_circle_radius:= 1.0
export var shape_ellipse_radius:= Vector2(2, 1)
among other properties and I want to detect any change (in this specific case from inspector) in any property which name is starting with shape_
.
This “solution” is verbose, mind-numbing, prone to bugs and doesn’t scale well:
export(SpawnShape) var shape_type:= SpawnShape.POINT setget _set_shape_type
export var shape_rectangle_size:= Vector2(1, 1) setget _set_shape_rectangle_size
export var shape_circle_radius:= 1.0 setget _set_shape_circle_radius
export var shape_ellipse_radius:= Vector2(2, 1) setget _set_shape_ellipse_radius
func _set_shape_type(x):
shape_type = x
update()
func _set_shape_rectangle_size(x):
shape_rectangle_size = x
update()
func _set_shape_circle_radius(x):
shape_circle_radius = x
update()
func _set_shape_ellipse_radius(x):
shape_ellipse_radius = x
update()