Using rule tiles with Tilemap.SetTiles()
I have code that collection positions and tiles and then does this:
_walkableTilemap.SetTiles(
walkableTilemapPositions.ToArray(),
walkableTilemapTiles.ToArray()
);
When walkableTilemapTiles
hold regular Tiles it works fine however when it hold Rule Tile, nothing happens (no errors but the tilemap is not updated. How do I get rule tiles to work with Tilemap.SetTiles()
?
Another weird that I notice if the the rule tiles work if there are up to 4 tiles being updated, once I am at 5 of higher, it then stops working.
// works
var t1 = new Vector3Int[] {
new Vector3Int(6, 5, 0),
new Vector3Int(7, 5, 0),
new Vector3Int(8, 5, 0),
new Vector3Int(9, 5, 0)
};
var t2 = new TileBase[] {
_floorTile,
_floorTile,
_floorTile,
_floorTile
};
_walkableTilemap.SetTiles(t1, t2);
// does not work
var t1 = new Vector3Int[] {
new Vector3Int(6, 5, 0),
new Vector3Int(7, 5, 0),
new Vector3Int(8, 5, 0),
new Vector3Int(9, 5, 0),
new Vector3Int(10, 5, 0)
};
var t2 = new TileBase[] {
_floorTile,
_floorTile,
_floorTile,
_floorTile,
_floorTile
};
_walkableTilemap.SetTiles(t1, t2);
Not sure why this is but thought it might be related so figure I would mention it.
Comment
Answer by ryanzec · Nov 30, 2021 at 01:13 PM
Guess this is a bug: https://forum.unity.com/threads/2021-2-0f1-tilemap-settiles-not-working-as-previous.1190572/#post-7624684