GetTilesBlockNonAlloc(BoundsInt, TileBase[])
Retrieves an array of Tiles with the given bounds.
Read time 1 minuteLast updated 5 days ago
Definition
- Type: Method
- Namespace: UnityEngine.Tilemaps
- Assembly: UnityEngine.TilemapModule
public int GetTilesBlockNonAlloc(BoundsInt bounds, TileBase[] tiles)
Parameters
Returns
Type | Description |
|---|---|
| int | Returns the number of Tiles retrieved, including null entries. |
Remarks
This is meant for more a performant way to get Tiles as a batch, when compared to calling Tilemap.GetTile for every single position. If the size of the arrays passed in as parameters are less than the number of Tiles within the range, the arrays will not be resized and the results will be limited.
Examples
// Retrieves all Tiles from an area on the Tilemap and prints out the Tiles to consoleusing UnityEngine;using UnityEngine.Tilemaps;public class ExampleClass : MonoBehaviour{ public BoundsInt area; void Start() { Tilemap tilemap = GetComponent<Tilemap>(); TileBase[] tileArray = new TileBase[16]; int count = tilemap.GetTilesBlockNonAlloc(area, tileArray); for (int index = 0; index < count; index++) { print(tileArray[index]); } }}