godot
godot copied to clipboard
Fix `find_children` doesn't work with class names
Script::get_name() and Script::get_path() of inner classes return empty values. I'm unsure whether this is a bug with scripting languages or by design. This PR only addresses the bug for the outer class.
Fix: #85690
What about the idea of adding a new parameter at the end of this function? This parameter would be a predicate function that takes the full path of the node it found, and the user will decide what to do with it.
find_children(..., Predicate p_pred = [](String path)->{return true}) const;
Of course, we could add support for global script classes in addition to native classes (registered in ClassDB). However, this raises a larger problem: we don't have first class types, i.e. a type to represent a type. Or at least a generic FQTN (fully qualified type name). Arbitrary types are not supported not only by find_node(), but also in the Inspector and other places. So, in addition to George's point, perhaps we should discuss the larger problem first before solving special cases?