I have to create nodes and manage the hierarchy at runtime. But I can’t find a way to set Inherit Alpha property of GUI nodes dynamically. Can you help?
Thanks
I have to create nodes and manage the hierarchy at runtime. But I can’t find a way to set Inherit Alpha property of GUI nodes dynamically. Can you help?
Thanks
Hmm, you’re right. We don’t have a way to change “inherit alpha” at runtime. Maybe there are unforeseen implications if this would be allowed? @sicher Do you know anything about this?
I hope that you guy can expose this as an API. Right now I have to keep all children nodes and children of children nodes and so on references in tables and use multiple nested for…in to call gui.animate() to just fading in and out all of them.
It will be a lot cleaner and easier just to animate the root node (top parent) by setting Inherit Alpha of all the children nodes when created them.
Another issue I can think right now is AP like gui.get_child(node, index) or gui.get_children(node) would be nice too.
Thanks
I see. But why do you sometimes need inherit alpa on and sometimes off for the same set of nodes?
Nope, I just need Inherit Alpha on all the time. But when create node with gui.new_box_node() it seems default to off.
Hmm, I really don’t know. But it seems like something we should look at.
Ah, I see. I rarely use gui.new_box_node(). Can’t you clone an existing box node (with Inherit Alpha enabled) using gui.clone() or hierarchy of nodes using gui.clone_tree() instead of creating nodes using gui.new_box_node()?
OK, creating temp box nodes with Inherit Alpha enabled in the editor (just for cloning) and using gui.clone() and gui.clone_tree() solved my problem. That’s a new way of thinking in Defold for me!
Thank you very much
Just a little bit more. Does gui.delete_node() also delete children nodes? Or I have to delete all the children nodes myself with looping call gui.delete_node() to avoid leak?
I found the answer from @britzl’s post at Factory for GUI?(SOLVED)
The answer is No, gui.delete_node() will not delete children nodes automatically. It would be nice to add this info to the doc.
It would be better to have gui.get_child(node, index) or gui.get_children(node) for this deleting purpose by loop through the children.
It would be great to have a function like gui.delete_nodes() (notice s) which deletes the given node and all of its children
Thanks
This seems to be something a lot of our users are missing. Maybe we need to address this in the future or make the documentation clearer on this point. What do you say @sicher? Is there something to be done on the documentation here?
As long as you are aware of this then it’s simple enough to save the returned id to node mapping returned by gui.clone_tree() and iterate it to delete nodes once they aren’t needed anymore. You could even put the iterate_and_delete_nodes snippet into a utility module.
Yes, save the table returned by gui.clone_tree() is my solution for now
Thank you very much
Yes, the API doc should definitely mention this. Other docs can probably be improved too, And maybe also an entry to the FAQ?