Version: 2021.2
言語: 日本語
public int GetTilesRangeCount (Vector3Int startPosition, Vector3Int endPosition);

パラメーター

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]); } } }