HELP -- How to count gui templates in a gui scene?

Hi there…i had a question that need a solution…i have a gui scene which have also multiple gui templates(buttons) inside…
How can i count the total number of gui templates(buttons) programmatically using lua code?..i am not a pro in lua code so i need some help from you guys…thanks!

It is your responsibility to keep track of such things.

If you are creating them based on code then you should add their address as you create them in a Lua table (which you can then get the total count from with #), and also have a button manager which keeps track of them.

If you are designing in the editor then have each button’s script init communicate with a master manager either via message passing (preferred) or a shared module import. Then you can build a list to know how many there are as messages come in, and be able to know the addresses to manage.

You probably want to have all buttons in one gui scene (as long as it makes sense) and this implies a single gui_script as well.

1 Like