| Parameter | Description |
|---|---|
| positionArray | 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 Tilemap.
Refer to Scriptable Tiles and Tilemap for more information.
// 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); } }
| Parameter | Description |
|---|---|
| tileChangeDataArray | The array of Tiles with additional properties to place. |
| ignoreLockFlags | Whether to ignore lock flags set in the tile's TileFlags when applying color and transform changes from TileChangeData. |
Sets an array of Tiles with additonal properties at the given XYZ coordinates of the corresponding cells in the Tilemap. The Color and Transform of the TileChangeData will take precedence over the values from the Tile.
Refer to Scriptable Tiles and Tilemap for more information.
| Parameter | Description |
|---|---|
| positionArray | The array of positions of tiles on the Tilemap. |
| tileArray | The array of Tiles to place. |
Sets an array of Tiles at the given XYZ coordinates of the corresponding cells in the Tilemap.
Refer to Scriptable Tiles and Tilemap for more information.
// Fills Tilemap area with checkerboard pattern of tileA and tileB using UnityEngine; using UnityEngine.Tilemaps; using Unity.Collections;
public class ExampleClass_Native : MonoBehaviour { public TileBase tileA; public TileBase tileB; public Vector2Int size;
void Start() { NativeArray<Vector3Int> positions = new NativeArray<Vector3Int>(size.x * size.y, Allocator.Temp); Tilemap.TileArray tileArray = new Tilemap.TileArray(positions.Length, Allocator.Temp);
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); } }
| Parameter | Description |
|---|---|
| positionArray | An array of positions of tiles on the Tilemap. |
| tileArray | The array of Tiles to place. |
| colorArray | The array of colors for tiles on the Tilemap. |
| transformArray | The array of transforms for tiles on the Tilemap. |
| ignoreLockFlags | Whether to ignore lock flags set in the tile's TileFlags when applying color and transform changes from TileChangeData. |
Sets an array of Tiles with additonal properties at the given XYZ coordinates of the corresponding cells in the Tilemap. The color and transform of the corresponding arrays will take precedence over the values from the Tile.
Refer to Scriptable Tiles and Tilemap for more information.
// Fills tilemap area with checkerboard pattern of tileA and tileB using UnityEngine; using UnityEngine.Tilemaps; using Unity.Collections;
public class ExampleClass_Native_Color_Transform : MonoBehaviour { public TileBase tileA; public TileBase tileB; public Vector2Int size;
void Start() { NativeArray<Vector3Int> positions = new NativeArray<Vector3Int>(size.x * size.y, Allocator.Temp); Tilemap.TileArray tileArray = new Tilemap.TileArray(positions.Length, Allocator.Temp); NativeArray<Color> colorArray = new NativeArray<Color>(positions.Length, Allocator.Temp); NativeArray<Matrix4x4> transformArray = new NativeArray<Matrix4x4>(positions.Length, Allocator.Temp);
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; colorArray[index] = index % 2 == 0 ? Color.white : Color.black; transformArray[index] = Matrix4x4.identity; }
Tilemap tilemap = GetComponent<Tilemap>(); tilemap.SetTiles(positions, tileArray, colorArray, transformArray, true); } }