How to add editor warnings for class members?

You can know when a variable is set with Object._set()

Example:


@tool
extends Area3D


func _get_configuration_warnings() -> PackedStringArray:
	var warnings = []
	if collision_layer == 2:
		warnings.push_back('Collision layer warning')
	if collision_mask == 2:
		warnings.push_back('Collision mask warning')

	return warnings


func _set(property: StringName, value: Variant) -> bool:
	match property:
		"collision_layer":
			update_configuration_warnings()
		"collision_mask":
			update_configuration_warnings()

	# Always return false as we aren't doing anything with the variables
	return false

3 Likes