I’m trying to get the editor to show a warning on a node when the collision layer and masks have a specific configuration. I know this is easily done via setters when doing it for a custom variable but I’m not sure how to do it for a class member.
I did find this thread but I’ll be honest, I have no idea what the answers are saying and I haven’t been able to get it working.
Well, I have made it somewhat work by calling update_configuration_warnings() on _process() but doing it this way feels icky, and also only updates the warnings when changing to a different scene and then back anyway, not in real time.
Thanks, but I’m not sure that answers my question, as it explains how to hook variables declared by the user, not variables that already exist in the class.
I can see that it is possible to call the update_configuration_warnings() from a variable setter, but it’s not possible (afaik) to add a setter for a variable that already exists, in my particular case, an Area3D’s collision_layer.
@tool
extends Area3D
func _get_configuration_warnings():
if collision_layer != 2:
return ["Collision layer should be set to 2"]
return []
func _validate_property(property: Dictionary):
if property.name == "collision_layer":
update_configuration_warnings()