Ejemplo n.º 1
0
    void Update()
    {
        Vector3    worldCoord = cam.ScreenToWorldPoint(Input.mousePosition);
        Vector3Int cell       = grid.WorldToCell(worldCoord);

        //cell.x = (int)Mathf.Clamp(cell.x, 0, mapHandler.MapSize.x);
        //cell.y = (int)Mathf.Clamp(cell.y, 0, mapHandler.MapSize.y);

        if (SelectedCell != cell)
        {
            tilemap.SetTile(SelectedCell, null);
            SelectedCell = cell;

            if (true || mapHandler.ContainsCell(cell))
            {
                if (Visible)
                {
                    tilemap.SetTile(cell, selectionTile);
                }
            }
        }
        //Vector3 localCoord = grid.WorldToLocal(worldCoord);
        //Debug.Log("cell is " + cell + " and local coordinates are " + localCoord);
    }