godot icon indicating copy to clipboard operation
godot copied to clipboard

GetChild(ren<T>) as analogy for the developers from other engines

Open Sythelux opened this issue 3 years ago • 2 comments

I come from a Unity, where we have a GetComponents<T>() and GetComponent<T>(), which basically returns is a children of the given Type T. Although we have the option to get a children in Godot by index or by name I was wondering if we could by type.

I know Unity has a component "database" of some kind, but I was able to break my use cases down to "I usually need a child or grandchild of said type" So I implemented a Solution with a level-order-search, which is a breadth-first-search specialised for trees and implemented it.

I can understand that this adds too much of time overhead in some cases so it might get denied, but it can be very useful in other cases, which I would love to share with developers.

Sythelux avatar Sep 27 '22 16:09 Sythelux

I think these types of additions are a better fit for a third party library considering how easily they can be added as extension methods in C#. Either way, this needs a proposal before it can be considered, including justification of why this feature needs to be core.

raulsntos avatar Sep 27 '22 22:09 raulsntos

I think these types of additions are a better fit for a third party library considering how easily they can be added as extension methods in C#. Either way, this needs a proposal before it can be considered, including justification of why this feature needs to be core.

I made one here: https://github.com/godotengine/godot-proposals/issues/5512

Sythelux avatar Sep 29 '22 07:09 Sythelux