Closed baochungit closed 7 months ago
I have succeeded. The way here is passing both template name and nodes (here is instance
) when creating a component.
function create_item(self, item, index, data_list)
local instance = gui.clone_tree(self.prefab)
gui.set_enabled(instance["item_prefab"], true)
local button = self.druid:new_button(instance["item_prefab"], function() pprint(item) end)
local player_avatar = self.druid:new(UIPlayerAvatar, "player_avatar", instance)
player_avatar:set_player(item)
button:set_click_zone(data_list.scroll.view_node)
return instance["item_prefab"], button
end
I'm trying to create a dynamic list but it's hard to have a template (which I'm going to use it as a druid component) inside a prefab. Could you provide an example of using it? It seems the template node will be dropped when clone_tree