Version: 2023.2
public void SetTiles (Vector3Int[] positionArray, TileBase[] tileArray);

参数

positionArray Tilemap 上的瓦片的位置数组。
tileArray An array of Tiles to be placed.

描述

Sets an array of Tiles at the given XYZ coordinates of the corresponding cells in the Tilemap.

请参阅可编程瓦片瓦片地图以了解更多信息。

// Fills Tilemap area with checkerboard pattern of tileA and tileB
using UnityEngine;
using UnityEngine.Tilemaps;

public class ExampleClass : MonoBehaviour { public TileBase tileA; public TileBase tileB; public Vector2Int size;

void Start() { Vector3Int[] positions = new Vector3Int[size.x * size.y]; TileBase[] tileArray = new TileBase[positions.Length];

for (int index = 0; index < positions.Length; index++) { positions[index] = new Vector3Int(index % size.x, index / size.y, 0); tileArray[index] = index % 2 == 0 ? tileA : tileB; }

Tilemap tilemap = GetComponent<Tilemap>(); tilemap.SetTiles(positions, tileArray); } }

public void SetTiles (TileChangeData[] tileChangeDataArray, bool ignoreLockFlags);

参数

tileChangeDataArray The array of Tiles with additional properties to place.
ignoreLockFlags Whether to ignore Lock Flags set in the Tile's TileFlags when applying Color and Transform changes from TileChangeData.

描述

Sets an array of Tiles with additonal properties at the given XYZ coordinates of the corresponding cells in the Tilemap. The Color and Transform of the TileChangeData will take precedence over the values from the Tile.

请参阅可编程瓦片瓦片地图以了解更多信息。