is it possible to use onmousedown with a tile grid collider type? When I set-up a tile, I can set a collider type, sprite or grid. I wanted to know if I could somehow use this collider with a mouse click so that if the tile is clicked on, something will happen. I tried attaching a script to both the grid and tilemap, but nothing happened when I clicked on the tile.
void OnMouseDown(){
Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector3Int coordinate = currentMap.WorldToCell(mouseWorldPos);
Tile t = currentMap.GetTile (coordinate) as Tile;
}
Any help is appreciated.