Hey all, experiencing this issue on the very latest version of unity (2022.2.1f1), but it was also occurring on the latest version of 2021 unity which I upgrade this project from to try and get it working.
As the title says, none of the Tilemap.FloodFill, BoxFill, or SetTilesBlock work for filling in a large portion of the tilemap with the same tile. For all 3 of the code snippets below, I get null in the second Debug:
FloodFill
BoundsInt zone = new BoundsInt(startX, startY, 0, sizeX, sizeY, 0); // startX, startY = 0, sizeX, sizeY = 8. But same issue occurs with any valid parameters
Tilemaps[0].SetTile(zone.min, BackgroundTile);
Tilemaps[0].SetTile(zone.max, BackgroundTile);
Tilemaps[0].FloodFill(zone.min, BackgroundTile);
Debug.Log(Tilemaps[0].GetTile(zone.min)); // Outputs name of the background tile
Debug.Log(Tilemaps[0].GetTile(zone.min + new Vector3Int(1, 1, 1))); // Outputs null
BoxFill
BoundsInt zone = new BoundsInt(startX, startY, 0, sizeX, sizeY, 0); // startX, startY = 0, sizeX, sizeY = 8. But same issue occurs with any valid parameters
Tilemaps[0].SetTile(zone.min, BackgroundTile);
Tilemaps[0].SetTile(zone.max, BackgroundTile);
Tilemaps[0].BoxFill(zone.min, BackgroundTile, 0, 0, sizeX - 1, sizeY - 1);
Debug.Log(Tilemaps[0].GetTile(zone.min)); // Outputs name of the background tile
Debug.Log(Tilemaps[0].GetTile(zone.min + new Vector3Int(1, 1, 1))); // Outputs null
SetTilesBlock
BoundsInt zone = new BoundsInt(startX, startY, 0, sizeX, sizeY, 0); // startX, startY = 0, sizeX, sizeY = 8. But same issue occurs with any valid parameters
TileBase[] background = new TileBase[sizeY * sizeY];
Array.Fill(background, BackgroundTile);
Tilemaps[0].SetTile(zone.min, BackgroundTile);
Tilemaps[0].SetTile(zone.max, BackgroundTile);
Tilemaps[0].SetTilesBlock(zone, background);
Debug.Log(Tilemaps[0].GetTile(zone.min)); // Outputs name of the background tile
Debug.Log(Tilemaps[0].GetTile(zone.min + new Vector3Int(1, 1, 1))); // Outputs null
The only way I can achieve filling in a large part of the map with the same tile is with SetTiles
BoundsInt zone = new BoundsInt(startX, startY, 0, sizeX, sizeY, 0); // startX, startY = 0, sizeX, sizeY = 8. But same issue occurs with any valid parameters
TileBase[] background = new TileBase[sizeY * sizeY];
Array.Fill(background, BackgroundTile);
Vector3Int[] backgroundPositions = new Vector3Int[sizeY * sizeY];
int index = 0;
for (int y = startY; y < startY + sizeY; y++)
{
for (int x = startX; x < startX + sizeX; x++)
{
backgroundPositions[index] = new Vector3Int(x, y, 0);
index++;
}
}
Tilemaps[0].SetTile(zone.min, BackgroundTile);
Tilemaps[0].SetTile(zone.max, BackgroundTile);
Tilemaps[0].SetTiles(backgroundPositions, background);
Debug.Log(Tilemaps[0].GetTile(zone.min)); // Outputs name of the background tile
Debug.Log(Tilemaps[0].GetTile(zone.min + new Vector3Int(1, 1, 1))); // Outputs name of background tile
However, this is not ideal due to just the amount of looping, especially when generating large maps (1024*1024) or having to perform this on many smaller tilemap layers. Any ideas what is causing this issue?

