tilemapTilesChanged
Callback when Tiles on a Tilemap have changed, without allocating.
Read time 1 minuteLast updated 8 days ago
Definition
- Type: Event
- Namespace: UnityEngine.Tilemaps
- Assembly: UnityEngine.TilemapModule
[NoAutoStaticsCleanup]public static event Action<Tilemap, NativeArray<Tilemap.SyncTile>, TileChangeReason> tilemapTilesChanged
Remarks
This returns the cells which have been updated and why. The cells are only valid for the duration of the callback.
Examples
// Log the cells which have changed, ignoring changes which cannot affect collisionusing Unity.Collections;using UnityEngine;using UnityEngine.Tilemaps;public class ExampleClass : MonoBehaviour{ void OnEnable() { Tilemap.tilemapTilesChanged += OnTilesChanged; } void OnDisable() { Tilemap.tilemapTilesChanged -= OnTilesChanged; } void OnTilesChanged(Tilemap tilemap, NativeArray<Tilemap.SyncTile> entries, TileChangeReason reason) { if ((reason & TileChangeReason.Physics) == 0) return; for (var i = 0; i < entries.Length; ++i) { var entry = entries[i]; Debug.Log(entry.hasTile ? $"{entry.position} has a Tile" : $"{entry.position} is empty"); } }}