Warning when children are missing

If I add for example a Area2D, it displays a yellow warning sign warning me that there are no required children (That being a Shape2D).
Can I implement this in my own node/script?

1 Like

Yes, there is a built-in function to nodes called _get_configuration_warnings() that you can declare and add custom warning to. You have to set the script as a @tool script for it to work. For example:

func _get_configuration_warnings() -> PackedStringArray:
  if get_child_count() == 0:
    return ["No children available"]
    return []

It expects that you return an Array of strings of the warning you want to display. The empty array means there is no warning to be shown. You can modify the conditionals to give a warning depending on what you want the Node to warn you about, in this case its if there is no children.

The documentation also has another tip you may want to look at


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.