More ways to get behaviors (generic method, in children)

At the moment Babylon only offers the method getBehaviorByName(name) to get behaviors.

Maybe it would be a good approach to get a behavior by type like so getBehavior<MyBehavior>(). With this way we do not have to cast the type of the behavior and we do not need to rely on the name string.

It would also be handy to have a method getBehaviorInChildren to get a behavior in the children of a Node.

I know that it is possible to extend IBehaviorAware<T>, but it would be good to have this on all native classes like Node, Mesh, etc.

Thank you!

Hey and welcome,
you still have node.behaviors as an array for you to do what you want

1 Like