Version: Unity 6.4 Alpha (6000.4)
LanguageEnglish
  • C#

Tilemap.GetTileEntityIdsFromOffsets

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public void GetTileEntityIdsFromOffsets(Vector3Int position, NativeArray<Vector3Int> offsets, NativeArray<EntityId> tileEntityIds);

Parameters

Parameter Description
position The position on the Tilemap.
offsets Offsets from the position on the Tilemap.
tileEntityIds Array to hold the resulting EntityIds.

Description

Gets an array of EntityIds at an offset from the position and stores them into the given array of EntityIds in the same order.

using Unity.Collections;
using UnityEngine;
using UnityEngine.Tilemaps;

public static class TilemapExample { public static void GetTileEntityIdFromOffsetsExample(Tilemap tilemap, Vector3Int position, Tile tile) { int count = 5; NativeArray<Vector3Int> offsets = new NativeArray<Vector3Int>(count, Allocator.Temp); NativeArray<EntityId> entityIds = new NativeArray<EntityId>(count, Allocator.Temp); for (var i = 0; i < count; i++) { offsets[i] = new Vector3Int(i, 0, 0); tilemap.SetTile(position + offsets[i], tile); } tilemap.GetTileEntityIdsFromOffsets(position, offsets, entityIds);

for (var i = 0; i < count; i++) { Debug.Log($"The ids for the Tile placed are equal ({(entityIds[i] == tile.GetEntityId()).ToString()})"); } } }