_validate_property not working with enums

Godot Version

4.2.2

Question

Hi, I don’t see what I’m doing wrong, I want to hide & show exported parameters in the editor but the following code from the docs does not work for me. I’m just using READ_ONLY to test it out but the print it’s not being triggered.

I found this issue with the solution but didn’t work for me, I even tried using @tool on the script but nothing changes:


@export var probability_type := PROBABILITY.WEIGHT:
	set(value):
		probability_type = value
		notify_property_list_changed()

func _validate_property(property: Dictionary):
	print("PROPERTY", property)
	if property.name in ["max_roll", "max_roll_items"] and probability_type == PROBABILITY.WEIGHT:
		property.usage |= PROPERTY_USAGE_READ_ONLY
	
	elif property.name in ["max_weight_items", "extra_weight_bias"] and probability_type == PROBABILITY.ROLL_TIER:
		property.usage |= PROPERTY_USAGE_READ_ONLY

Works for me (when ran as a tool script). If you don’t see the print regardless, the tool probably hasn’t registered properly yet. Try restarting the engine.

1 Like

Ah yeah worked for me this morning when I reopened it, how I could not come up with the universal solution to any computer problem…

1 Like