Over the weekend I got obelisks stacking programmatically. You’re able to sort through all the tiles on a tilemap a couple of ways in unity and I had to try a few. Initially I was getting the bounds of a tilemap using -

 
BoundsInt bounds = groundMap.cellBounds; 

and then getting all of the tiles from that using -

TileBase[] allTiles = groundMap.GetTilesBlock(bounds); 

which gives you an array that you can loop through, except whoops, then you don’t have the grid co-ordinates of the tiles you’re looking at. I’ve switched to this which seems to mostly be working?

void Start()
    {
        int ObeliskID = 1;  // we're going to number each obelisk we find
        Vector3Int coordinate = new Vector3Int(0, 0, 0);
        for (int i = 0; i < groundMap.size.x; i++)
        {
            for (int j = 0; j < groundMap.size.y; j++)
            {
                coordinate.x = i; coordinate.y = j;
                Tile tile = groundMap.GetTile<Tile>(coordinate);
                if (tile != null)
                {
                    Debug.Log("x:" + coordinate.x + " y:" + coordinate.y + " tile:" + tile.name);
                    if (tile.name == "foundation_block")
                    {
                        //Vector3Int foundationCoords = new Vector3Int(coordinate.x, coordinate.y, 0);
                        navMap.SetTile(coordinate, pathStop); // add a pathfinding barrier
                        GrowObelisk(coordinate, 4, ObeliskID);
                        numberOfObelisks += 1;
                        ObeliskID += 1;
                    }
                }
                
            }
        }
    }

it finds tileBases, which you can then get Tile from, which has grid coordinates and the name of the sprite the tile has (or null). For some reason though, it’s not finding a couple of tiles I’m looking for at the bottom of my map. Are they out of bounds? It’s possible groundMap size is drawing the right sized rectangle of bounds, but only using positive numbers, so the bounding rectangle I am checking is shifted off to the right and up (I’m actually pretty sure that’s what’s happening) so I’ll have to offset the bounds to be centered. I’ll need a nap before I can figure that out. game screenshot of stacked blocks on grid