Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
ClosepositionArray | An array of positions of Tiles on the Tilemap. |
tileArray | An array of Tiles to be placed. |
Sets an array of tiles at the given XYZ coordinates of the corresponding cells in the tile map.
// Fills tilemap area with checkerboard pattern of tileA and tileB using UnityEngine; using UnityEngine.Tilemaps;
public class ExampleClass : MonoBehaviour { public TileBase tileA; public TileBase tileB; public Vector2Int size;
void Start() { Vector3Int[] positions = new Vector3Int[size.x * size.y]; TileBase[] tileArray = new TileBase[positions.Length];
for (int index = 0; index < positions.Length; index++) { positions[index] = new Vector3Int(index % size.x, index / size.y, 0); tileArray[index] = index % 2 == 0 ? tileA : tileB; }
Tilemap tilemap = GetComponent<Tilemap>(); tilemap.SetTiles(positions, tileArray); } }