I have some problems with gui templates
My situation: I have a gui, which have root and child - one template “event_button”. And in code buttons created, added and etc. And now I need to add new type of button - “score_button”, which has another template “score_button”.
In code I create one event_button, then one score_button. And the problem is - event_button on screen consist both buttons - event and score. How templates works? I thought that template doesn’t exist actually, only when I added it in code. But practically both buttons appears… Where I’m wrong?
Node hierarchy below:
No, a template exists as soon as it is added to a .gui. The purpose of template files is to allow you to define a button in one place and then reuse the design in multiple places. And when you change the template all places where it is used will be updated.
Add one instance of each template to your GUI scene and start by disabling both using gui.set_enabled(node, false). You can then enable them as needed or use gui.clone_tree(node) to clone the nodes if you need more instances.