Naming child elements on a uniform grid panel

Hi, I’m dynamically making a uniform grid panel full of buttons(a WB of its own), and I’m trying to name the buttons after their column and row(0,0 0,1 0,2 etc.) to reference them later, but I’m not sure where or how in the creation process to do that.

I want to say that why is a better question here - why do you feel you need to reference 625 buttons by name? You may have a great reason and there really is no other way but, perhaps, you’re overlooking a much simpler solution…


If you absolutely must do it this way, I’d opt for a map:

Untested but I think commas work in Names. Worst case scenario, you can use a string.

I’m working on a game that will largely be based on this grid, I’d love to hear better solutions to referencing specific tiles on a large map. Any help is appreciated! And also thank you for the solution as well.

The approach would very heavily depend on why, how and what you’re going to use the references for. Are they even necessary to start with? Oftentimes they are not.

If I wanted to click on a grid tile and have something move there, I would not need to reference anything - not manually like you’re trying; I’d use an Event Dispatcher instead and have the button produce the necessary data rather than compare what I clicked to what I can find in some elaborate list.


working on a game that will largely be based on this grid

What will it be similar to? Chess? A boardgame? Civ-like strategy? Minecraft / Terraria chunks / blocks, Minesweeper?

If you interact with a grid piece, the piece will tell you everything there is to know about itself without you referencing anything. But I can imagine a puzzle game where you do not interact with blocks and must look them up. A map would be quite efficient here.

1 Like