public void PlaceBuilding() { PathNode topRight = worldGrid.GetNodeFromWorldPoint(building.transform.position + halfExtents); PathNode bottomLeft = worldGrid.GetNodeFromWorldPoint(building.transform.position - halfExtents); int width = topRight.gridX - bottomLeft.gridX + 1; int height = topRight.gridY - bottomLeft.gridY + 1; if (width == 0 || height == 0) { return; } PathGrid.Coord[] coords = new PathGrid.Coord[width * height]; int i = 0; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { coords[i].x = bottomLeft.gridX + x; coords[i].y = bottomLeft.gridY + y; i++; } } worldGrid.UpdateUnwalkable(coords); }