Use _validate_property() in scripting with Resources to hide var in inspector

Godot Version



Hi everyone,

I have a custom resource which instances can or not be in a list (represented by a bool). If it’s not I want to hide the var that concerns only those in the list (bool true).
I found something pertinent there : Ability to dynamically hide exported variables in the inspector · Issue #1056 · godotengine/godot-proposals · GitHub and I tried to adapt the example code to my project. It doesn’t work though, the var stays visible. Can anyone help me, or tell me if it’s because I try it from a resource and not a node ?

Simplified / cut code :

extends Resource
class_name DataResource

@export var is_in_daily_report := false :
		is_in_daily_report = value

@export var test : int

func _validate_property(property: Dictionary):
	if in ["test"] and is_in_daily_report == false :
		property.usage = PROPERTY_USAGE_NO_EDITOR

Alright, I just reloaded the whole project for something else and it now works !