Reply From: | thenegativehunter |
nevermind i figured it out. example :
@export var surfaceColors: PackedFloat32Array = [1.0] :
get:
return surfaceColors
set(value):
surfaceColors = value
This appears to be broken in the betas. I’m using beta 6 (I didn’t try it until the betas, so I don’t know if it ever worked in Godot 4). Does it still work for you?
@export var m_vecSize:Vector3 = Vector3(1,1,1) : set = setSize, get = getSize
func getSize():
print(“Return size”)
return m_vecSize
func setSize(a):
print(“Change size”)
m_vecSize = a
Neither getSize() nor setSize() get called when changing the value in the editor. The editor shows that the engine recognizes the change, but my set and get methods don’t get called then.
Any ideas?
stormreaver | 2022-11-27 13:01
I am experiencing this issue as well in v4.0.2:
@tool
class_name CelestialBodyData extends Resource
@export_range(1, 20) var radius: int = 1:
set(new_value):
prints('SET: radius:', new_value)
if not radius == new_value:
radius = new_value
emit_changed()
The value does change, but I never see the prints
output, also, the emit_changed
method does not fire.
Any thoughts or suggestions?
Thanks,
h4v0c
h4v0c | 2023-04-17 00:22
Maybe, if not radius == new_value:, should be: if radius != new_value:?
CassanovaWong | 2023-05-14 22:49
Yeah, lol, I don’t know why I wrote it like that…
h4v0c | 2023-05-15 10:23