startPosition | The starting position of the range to retrieve Tiles from. |
endPosition | The ending position of the range to retrieve Tiles from. |
positions | The positions of Tiles within the given range. |
tiles | The Tiles within the given range. |
int Returns the number of positions and Tiles retrieved.
Retrieves an array of Tiles within the given range.
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.
// Retrieves all tiles with a range on the tilemap and prints out the positions and tiles to console using UnityEngine; using UnityEngine.Tilemaps;
public class ExampleClass : MonoBehaviour { void Start() { Vector3Int[] positions = new Vector3Int[11]; TileBase[] tiles = new TileBase[11]; Tilemap tilemap = GetComponent<Tilemap>(); var count = tilemap.GetTilesRangeNonAlloc(new Vector3Int(0, 0, 0), new Vector3Int(10, 0, 0), positions, tiles); for (int index = 0; index < count; index++) { print(positions[index]); print(tiles[index]); } } }