Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SetTilesBlock(BoundsInt, TileBase[])

Fills bounds with array of Tile s.
Read time 1 minuteLast updated 6 days ago

Definition

public void SetTilesBlock(BoundsInt position, TileBase[] tileArray)

Parameters

position

Bounds to be filled.

tileArray

An array of Tiles to be placed.

Remarks

This is meant for a more performant way to set Tiles as a batch, when compared to calling SetTile for every single Tile. The bounds size must match the array size. For example bounds of 1x2x3 needs an array length of 6.
// Fill area on Tilemap with checkerboard pattern of tileA and tileBusing UnityEngine;using UnityEngine.Tilemaps;public class ExampleClass : MonoBehaviour{ public TileBase tileA; public TileBase tileB; public BoundsInt area; void Start() { TileBase[] tileArray = new TileBase[area.size.x * area.size.y * area.size.z]; for (int index = 0; index < tileArray.Length; index++) { tileArray[index] = index % 2 == 0 ? tileA : tileB; } Tilemap tilemap = GetComponent<Tilemap>(); tilemap.SetTilesBlock(area, tileArray); }}
Refer to Scriptable Tiles and Tilemap for more information.