startPosition | The starting position of the range to retrieve Tiles from. |
endPosition | The ending position of the range to retrieve Tiles from. |
int Returns the number of Tiles within the given range.
Retrieves the number of Tiles within the given range.
The range is inclusive of the endPosition parameter.
// 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() { Tilemap tilemap = GetComponent<Tilemap>(); var count = tilemap.GetTilesRangeCount(new Vector3Int(0, 0, 0), new Vector3Int(10, 0, 0)); Vector3Int[] positions = new Vector3Int[count]; TileBase[] tiles = new TileBase[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]); } } }