Gui templates

Hi everybody!

I have some problems with gui templates :slight_smile:
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:
image

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.

1 Like

Oh… So, can you please help me with this? How can I use two templates, but show them “customly”? ((

And by the way, why when I added score_button, event_button didn’t added?..

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.

1 Like