# RefreshTile(Vector3Int, ITilemap)

> This method is called when the tile is refreshed.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.Tilemaps](/engine/6000.5/script-reference/unityengine/tilemaps.md)
* **Assembly:** UnityEngine.TilemapModule

```csharp
public virtual void RefreshTile(Vector3Int position, ITilemap tilemap)
```

### Parameters

**** (\[Vector3Int]\(/engine/6000.5/script-reference/unityengine/vector3int)): Position of the Tile on the [Tilemap](/engine/6000.5/script-reference/unityengine/tilemaps/tilemap.md).**** (\[ITilemap]\(/engine/6000.5/script-reference/unityengine/tilemaps/itilemap)): The [Tilemap](/engine/6000.5/script-reference/unityengine/tilemaps/tilemap.md) the tile is present on.

### Remarks

Implement this and call [Tilemap.RefreshTile](/engine/6000.5/script-reference/unityengine/tilemaps/tilemap/refreshtile.md) on all affected tiles on the [Tilemap](/engine/6000.5/script-reference/unityengine/tilemaps/tilemap.md) including the tile at the given position to refresh them. This is also useful if the placement of a tile affects the properties of neighboring tiles.

### Examples

```csharp
using UnityEngine;
using UnityEngine.Tilemaps;

// Tile that displays a Sprite when it is alone and a different Sprite when it is orthogonally adjacent to the same NeighourTile
[CreateAssetMenu]
public class NeighbourTile : TileBase
{
    public Sprite spriteA;
    public Sprite spriteB;

    public override void RefreshTile(Vector3Int position, ITilemap tilemap)
    {
        for (int yd = -1; yd <= 1; yd++)
        {
            Vector3Int location = new Vector3Int(position.x, position.y + yd, position.z);
            if (IsNeighbour(location, tilemap))
                tilemap.RefreshTile(location);
        }
        for (int xd = -1; xd <= 1; xd++)
        {
            Vector3Int location = new Vector3Int(position.x + xd, position.y, position.z);
            if (IsNeighbour(location, tilemap))
                tilemap.RefreshTile(location);
        }
    }

    public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData)
    {
        tileData.sprite = spriteA;
        for (int yd = -1; yd <= 1; yd += 2)
        {
            Vector3Int location = new Vector3Int(position.x, position.y + yd, position.z);
            if (IsNeighbour(location, tilemap))
                tileData.sprite = spriteB;
        }
        for (int xd = -1; xd <= 1; xd += 2)
        {
            Vector3Int location = new Vector3Int(position.x + xd, position.y, position.z);
            if (IsNeighbour(location, tilemap))
                tileData.sprite = spriteB;
        }
    }

    private bool IsNeighbour(Vector3Int position, ITilemap tilemap)
    {
        TileBase tile = tilemap.GetTile(position);
        return (tile != null && tile == this);
    }
}
```
