Skip to content

Instantly share code, notes, and snippets.

View dri-richard's full-sized avatar

Richard Bates dri-richard

  • Dream Reality Interactive
View GitHub Profile
@dri-richard
dri-richard / build_hierarchy.lua
Created August 13, 2023 17:09
Get a full gui node hierarchy from a specified root id in the Defold engine
function build_hierarchy(root)
local node_and_descendants = {}
local node_info = {}
local all_nodes = gui.get_tree(gui.get_node(root))
-- Build an array of (node + its descendants) for each node
for node_id,_ in pairs(all_nodes) do
local nodes
if node_id == root then
nodes = all_nodes -- avoid calling get_tree again for the root node