Fill an empty isometric Tilemap from script:
This doesn’t work: ([u]Unity 2019.4.5f1 personal)[/u]
map.size.Set(10, 10, 1);
map.BoxFill(new Vector3Int(0, 0, 0), tile, -5, -5, 4, 4);
Debug.Log("bounds: " + map.cellBounds);
The size of an empty tilemap cannot be changed by map.size.Set(…)
Therefore BoxFill will do nothing, see the API docs:
If the limits are larger than the tilemap bounds, the limits will be capped to the tilemap bounds.
Here’s a workaround:
Put a tile at the min and max position of your desired area and then use BoxFill:
/* it won't work when calling BoxFill before setting the min and max tile: */
//map.BoxFill(new Vector3Int(0, 0, 0), tiles[0], -5, -5, 4, 4);
Vector3Int minPos = new Vector3Int(-5, -5, 0);
Vector3Int maxPos = new Vector3Int(4, 4, 0);
map.SetTile(minPos, tile);
map.SetTile(maxPos, tile);
map.BoxFill(new Vector3Int(0, 0, 0), tile, -5, -5, 4, 4);
Debug.Log("bounds: " + map.cellBounds);
WARNING:
When you call BoxFill before setting the min and the max tile, the map gets somehow corrupted and subsequent calls of BoxFill after setting the tiles don’t do anything.