Getting gui node hierarchy

gui.get_tree() added in Defold 1.4.8 and gui.clone_tree() return a table of node ids and nodes, which is really useful , but sometimes it would be good to have the full node hierarchy, and that’s tricky.

This function does that. Call it with the node id of your root node and it figures out the hierarchy, returning a table containing info on the root and its direct children, which can be navigated down the tree.

Would be interesting to know if there’s a more efficient way of achieving the same result.

8 Likes