Version: 2021.2
언어: 한국어

Tilemap.GetTilesRangeCount

매뉴얼로 전환
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]); } } }