tilemapTilesChanged
Callback when Tiles on a Tilemap have changed, without allocating.
読み終わるまでの所要時間 1 分最終更新 12時間前
Definition
- Type: Event
- Namespace: UnityEngine.Tilemaps
- Assembly: UnityEngine.TilemapModule
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. The Tilemap reports animation frames only for tiles whose animation has TileAnimationFlags.UpdatePhysics. It reports them once each time it updates its animations, and once for each call to Tilemap.SetAnimationFrame or Tilemap.SetAnimationTime. When Tilemap.ClearAllTiles clears every tile, the Tilemap reports it with Tilemap.tilemapChanged instead.
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"); } }}