How get all button nodes from a parent node

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By voylin

Hey guy’s, I’ve been struggling a bit with getting a for loop going to get all child nodes which are buttons into a list. I can’t figure out how to catch all child objects of a node, this is my code:

func on_option_buttonPressed(value):
for x in $ChooseGame/CC/PanelContainer/ChooseGameOptions:

Does anybody have any idea how to do this? ^^"

:bust_in_silhouette: Reply From: kidscancode

You can get a node’s children using Node.get_children():

This returns an array, which you can loop through:

for x in $SomeNode.get_children():

Thank you so much, I was thinking about this the whole day already and now that I know the answer it sounds so logical ^^" I kind of feel a bit dumb right now for not thinking about that earlier.

Thanks again :smiley:

voylin | 2019-12-10 16:59