How can I disable an @export_tool_button?

Godot Version

4.5.1

Question

I have a @tool script with an @export_tool_button:

@export_tool_button("compute_progress") var compute_progress = _compute_progress

compute_progress is a function that may take some time to finish and I don’t want it to be called again before it finishes. Is there a way to disable the button in the UI? I’m currently using a flag in my script to ignore the click while the function is computing but I’d like to have that visual hint in the editor.

Thanks!

Toggle the property by toggling PROPERTY_USAGE_READ_ONLY flag in Object::_validate_property(). Use Object::notify_property_list_changed() to refresh the inspector which will invoke _validate_property()
You can also temporarily hide the button by toggling PROPERTY_USAGE_EDITOR instead.

1 Like