Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get all nodes recursively #13

Open
me2beats opened this issue Dec 19, 2021 · 0 comments
Open

Get all nodes recursively #13

me2beats opened this issue Dec 19, 2021 · 0 comments

Comments

@me2beats
Copy link
Owner

me2beats commented Dec 19, 2021

Tip-trick:
A simple method to get all nodes recursively, starting from a root node (specified as an argument).

static func get_nodes(node:Node)->Array:
	var nodes = []
	var stack = [node]
	while stack:
		var n = stack.pop_back()
		nodes.push_back(n)
		stack.append_array(n.get_children())
	return nodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant