public override void OnPaintSceneGUI(GridLayout grid, GameObject brushTarget, BoundsInt position, GridBrushBase.Tool tool, bool executing) { base.OnPaintSceneGUI(grid, brushTarget, position, tool, executing); if (coordinateBrush.z != 0) { var zPosition = new Vector3Int(position.min.x, position.min.y, coordinateBrush.z); var newPosition = new BoundsInt(zPosition, position.size); var cellLocals = new[] { grid.CellToLocal(new Vector3Int(newPosition.min.x, newPosition.min.y, newPosition.min.z)), grid.CellToLocal(new Vector3Int(newPosition.max.x, newPosition.min.y, newPosition.min.z)), grid.CellToLocal(new Vector3Int(newPosition.max.x, newPosition.max.y, newPosition.min.z)), grid.CellToLocal(new Vector3Int(newPosition.min.x, newPosition.max.y, newPosition.min.z)) }; Handles.color = Color.blue; var i = 0; for (var j = cellLocals.Length - 1; i < cellLocals.Length; j = i++) { Handles.DrawLine(cellLocals[j], cellLocals[i]); } } Handles.Label(grid.CellToWorld(new Vector3Int(position.x, position.y, coordinateBrush.z)), new Vector3Int(position.x, position.y, coordinateBrush.z).ToString()); }
public override void OnPaintSceneGUI(GridLayout grid, GameObject brushTarget, BoundsInt position, GridBrushBase.Tool tool, bool executing) { base.OnPaintSceneGUI(grid, brushTarget, position, tool, executing); if (position.z != 0) { var zPosition = new Vector3Int(position.min.x, position.min.y, position.min.z); BoundsInt newPosition = new BoundsInt(zPosition, position.size); Vector3[] cellLocals = new Vector3[] { grid.CellToLocal(new Vector3Int(newPosition.min.x, newPosition.min.y, newPosition.min.z)), grid.CellToLocal(new Vector3Int(newPosition.max.x, newPosition.min.y, newPosition.min.z)), grid.CellToLocal(new Vector3Int(newPosition.max.x, newPosition.max.y, newPosition.min.z)), grid.CellToLocal(new Vector3Int(newPosition.min.x, newPosition.max.y, newPosition.min.z)) }; Handles.color = Color.blue; int i = 0; for (int j = cellLocals.Length - 1; i < cellLocals.Length; j = i++) { Handles.DrawLine(cellLocals[j], cellLocals[i]); } } var labelText = "Pos: " + new Vector3Int(position.x, position.y, position.z); if (position.size.x > 1 || position.size.y > 1) { labelText += " Size: " + new Vector2Int(position.size.x, position.size.y); } Handles.Label(grid.CellToWorld(new Vector3Int(position.x, position.y, position.z)), labelText); }
public static void DrawSelectedHexGridArea(GridLayout gridLayout, BoundsInt area, Color color) { int requiredVertices = 4 * (area.size.x + area.size.y) - 2; if (requiredVertices < 0) { return; } Vector3[] cellLocals = new Vector3[requiredVertices]; int horizontalCount = area.size.x * 2; int verticalCount = area.size.y * 2 - 1; int bottom = 0; int top = horizontalCount + verticalCount + horizontalCount - 1; int left = requiredVertices - 1; int right = horizontalCount; Vector3[] cellOffset = { Grid.Swizzle(gridLayout.cellSwizzle, new Vector3(0, gridLayout.cellSize.y / 2, area.zMin)), Grid.Swizzle(gridLayout.cellSwizzle, new Vector3(gridLayout.cellSize.x / 2, gridLayout.cellSize.y / 4, area.zMin)), Grid.Swizzle(gridLayout.cellSwizzle, new Vector3(gridLayout.cellSize.x / 2, -gridLayout.cellSize.y / 4, area.zMin)), Grid.Swizzle(gridLayout.cellSwizzle, new Vector3(0, -gridLayout.cellSize.y / 2, area.zMin)), Grid.Swizzle(gridLayout.cellSwizzle, new Vector3(-gridLayout.cellSize.x / 2, -gridLayout.cellSize.y / 4, area.zMin)), Grid.Swizzle(gridLayout.cellSwizzle, new Vector3(-gridLayout.cellSize.x / 2, gridLayout.cellSize.y / 4, area.zMin)) }; // Fill Top and Bottom Vertices for (int x = area.min.x; x < area.max.x; x++) { cellLocals[bottom++] = gridLayout.CellToLocal(new Vector3Int(x, area.min.y, area.zMin)) + cellOffset[4]; cellLocals[bottom++] = gridLayout.CellToLocal(new Vector3Int(x, area.min.y, area.zMin)) + cellOffset[3]; cellLocals[top--] = gridLayout.CellToLocal(new Vector3Int(x, area.max.y - 1, area.zMin)) + cellOffset[0]; cellLocals[top--] = gridLayout.CellToLocal(new Vector3Int(x, area.max.y - 1, area.zMin)) + cellOffset[1]; } // Fill first Left and Right Vertices cellLocals[left--] = gridLayout.CellToLocal(new Vector3Int(area.min.x, area.min.y, area.zMin)) + cellOffset[5]; cellLocals[top--] = gridLayout.CellToLocal(new Vector3Int(area.max.x - 1, area.max.y - 1, area.zMin)) + cellOffset[2]; // Fill Left and Right Vertices for (int y = area.min.y + 1; y < area.max.y; y++) { cellLocals[left--] = gridLayout.CellToLocal(new Vector3Int(area.min.x, y, area.zMin)) + cellOffset[4]; cellLocals[left--] = gridLayout.CellToLocal(new Vector3Int(area.min.x, y, area.zMin)) + cellOffset[5]; } for (int y = area.min.y; y < (area.max.y - 1); y++) { cellLocals[right++] = gridLayout.CellToLocal(new Vector3Int(area.max.x - 1, y, area.zMin)) + cellOffset[2]; cellLocals[right++] = gridLayout.CellToLocal(new Vector3Int(area.max.x - 1, y, area.zMin)) + cellOffset[1]; } GL.PushMatrix(); GL.MultMatrix(gridLayout.transform.localToWorldMatrix); GL.Begin(GL.LINES); GL.Color(color); int i = 0; for (int j = cellLocals.Length - 1; i < cellLocals.Length; j = i++) { DrawBatchedLine(cellLocals[j], cellLocals[i]); } GL.End(); GL.PopMatrix(); }
public override void OnPaintSceneGUI(GridLayout gridLayout, GameObject brushTarget, BoundsInt position, GridBrushBase.Tool tool, bool executing) { lastBoundsInt = position; //base.OnPaintSceneGUI(gridLayout, brushTarget, position, tool, executing); //Handles.Label(gridLayout.CellToWorld(position.position), position.position.ToString()); var zPosition = new Vector3Int(position.min.x, position.min.y, position.min.z); BoundsInt newPosition = new BoundsInt(zPosition, position.size); Vector3 offset = new Vector3(0f, 0f, -0.1f); Vector3[] cellLocals = new Vector3[] { gridLayout.CellToLocal(new Vector3Int(newPosition.min.x, newPosition.min.y, newPosition.min.z)) + offset, gridLayout.CellToLocal(new Vector3Int(newPosition.max.x, newPosition.min.y, newPosition.min.z)) + offset, gridLayout.CellToLocal(new Vector3Int(newPosition.max.x, newPosition.max.y, newPosition.min.z)) + offset, gridLayout.CellToLocal(new Vector3Int(newPosition.min.x, newPosition.max.y, newPosition.min.z)) + offset }; Handles.color = Color.blue; int index = 0; for (int j = cellLocals.Length - 1; index < cellLocals.Length; j = index++) { Handles.DrawLine(cellLocals[j], cellLocals[index]); } var labelText = "Pos: " + new Vector3Int(position.x, position.y, position.z); if (position.size.x > 1 || position.size.y > 1) { labelText += " Size: " + new Vector2Int(position.size.x, position.size.y); } Handles.Label(gridLayout.CellToWorld(new Vector3Int(position.x, position.y, position.z)) + offset, labelText); }
// Start is called before the first frame update void Start() { Game.GenerateFood(); PlayerPosition = PlayGround.LocalToCell(transform.position); PlayerBody = new Vector3Int[1]; PlayerBody.SetValue(PlayerPosition, 0); transform.localPosition = PlayGround.CellToLocal(PlayerPosition); PlayMap.SetTile(PlayerPosition, PlayerAvatar); MoveTimeStamp = Time.time; PositionChanger = new Vector3Int(0, 1, 0); }
public static void DrawGridMarquee(GridLayout gridLayout, BoundsInt area, Color color) { if (gridLayout == null) { return; } switch (gridLayout.cellLayout) { case GridLayout.CellLayout.Hexagon: DrawSelectedHexGridArea(gridLayout, area, color); break; case GridLayout.CellLayout.Isometric: case GridLayout.CellLayout.IsometricZAsY: case GridLayout.CellLayout.Rectangle: var cellStride = gridLayout.cellSize + gridLayout.cellGap; var cellGap = Vector3.one; if (!Mathf.Approximately(cellStride.x, 0f)) { cellGap.x = gridLayout.cellSize.x / cellStride.x; } if (!Mathf.Approximately(cellStride.y, 0f)) { cellGap.y = gridLayout.cellSize.y / cellStride.y; } Vector3[] cellLocals = { gridLayout.CellToLocal(new Vector3Int(area.xMin, area.yMin, area.zMin)), gridLayout.CellToLocalInterpolated(new Vector3(area.xMax - 1 + cellGap.x, area.yMin, area.zMin)), gridLayout.CellToLocalInterpolated(new Vector3(area.xMax - 1 + cellGap.x, area.yMax - 1 + cellGap.y, area.zMin)), gridLayout.CellToLocalInterpolated(new Vector3(area.xMin, area.yMax - 1 + cellGap.y, area.zMin)) }; HandleUtility.ApplyWireMaterial(); GL.PushMatrix(); GL.MultMatrix(gridLayout.transform.localToWorldMatrix); GL.Begin(GL.LINES); GL.Color(color); int i = 0; for (int j = cellLocals.Length - 1; i < cellLocals.Length; j = i++) { DrawBatchedLine(cellLocals[j], cellLocals[i]); } GL.End(); GL.PopMatrix(); break; } }
void MoveIn(Vector3Int tile) { //if (index <= moveDistance) //{ // index += interval; // panel.transform.Translate(Vector3.right * interval); //} Vector3 temp = tile + new Vector3(0.5f, 0.5f, 0); temp = Camera.main.WorldToScreenPoint(myGrid.CellToLocal(tile) + new Vector3(0.5f, 0.5f, 0)); panel.GetComponent <RectTransform>().position = temp; panel.GetComponent <Animator>().Play("Fade in"); }
public override void Paint(GridLayout gridLayout, GameObject brushTarget, Vector3Int position) { GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)); var obj = PrefabUtility.InstantiatePrefab(prefab) as GameObject; obj.transform.position = gridLayout.LocalToWorld(gridLayout.CellToLocal(position)); obj.transform.position = new Vector3(obj.transform.position.x + 0.5f, obj.transform.position.y, obj.transform.position.z); // Technique de sioux tilemap = GameObject.Find(parentGameObjectName).transform; obj.transform.SetParent(tilemap.transform); Undo.RegisterCreatedObjectUndo(obj, "Create"); }
public override void OnPaintSceneGUI(GridLayout grid, GameObject brushTarget, BoundsInt position, GridBrushBase.Tool tool, bool executing) { base.OnPaintSceneGUI(grid, brushTarget, position, tool, true); //Tilemap layerTilemap = brushTarget.GetComponent<Tilemap>(); UnitSpawner spawner = brushTarget.GetComponent <UnitSpawner>(); if (spawner == null) { return; } int i = 0; Handles.color = Color.red; foreach (var p in spawner.spawns) { Vector3 wp = grid.CellToLocal(p.position) + brushTarget.transform.position; Handles.RectangleHandleCap(i, wp + grid.cellSize / 2, Quaternion.identity, 8f, EventType.Repaint); Handles.Label(wp, "生怪器"); i++; } }
public static void DrawGridMarquee(GridLayout gridLayout, BoundsInt area, Color color) { Vector3 cellStride = gridLayout.cellSize + gridLayout.cellGap; Vector3 cellGap = Vector3.one; if (!Mathf.Approximately(cellStride.x, 0f)) { cellGap.x = gridLayout.cellSize.x / cellStride.x; } if (!Mathf.Approximately(cellStride.y, 0f)) { cellGap.y = gridLayout.cellSize.y / cellStride.y; } Vector3[] cellLocals = { gridLayout.CellToLocal(new Vector3Int(area.xMin, area.yMin, 0)), gridLayout.CellToLocalInterpolated(new Vector3(area.xMax - 1 + cellGap.x, area.yMin, 0)), gridLayout.CellToLocalInterpolated(new Vector3(area.xMax - 1 + cellGap.x, area.yMax - 1 + cellGap.y, 0)), gridLayout.CellToLocalInterpolated(new Vector3(area.xMin, area.yMax - 1 + cellGap.y, 0)) }; HandleUtility.ApplyWireMaterial(); GL.PushMatrix(); GL.MultMatrix(gridLayout.transform.localToWorldMatrix); GL.Begin(GL.LINES); GL.Color(color); int i = 0; for (int j = cellLocals.Length - 1; i < cellLocals.Length; j = i++) { DrawBatchedLine(cellLocals[j], cellLocals[i]); } GL.End(); GL.PopMatrix(); }
private static Mesh GenerateCachedHexagonalGridMesh(GridLayout gridLayout, Color color) { Mesh mesh = new Mesh(); mesh.hideFlags = HideFlags.HideAndDontSave; int vertex = 0; int max = k_GridGizmoVertexCount / (2 * (6 * 2)); max = (max / 4) * 4; int min = -max; float numVerticalCells = 6 * (max / 4); int totalVertices = max * 2 * 6 * 2; var cellStrideY = gridLayout.cellGap.y + gridLayout.cellSize.y; var cellOffsetY = gridLayout.cellSize.y / 2; var hexOffset = (1.0f / 3.0f); var drawTotal = numVerticalCells * 2.0f * hexOffset; var drawDiagTotal = 2 * drawTotal; Vector3[] vertices = new Vector3[totalVertices]; Vector2[] uvs2 = new Vector2[totalVertices]; // Draw Vertical Lines for (int x = min; x < max; x++) { vertices[vertex] = gridLayout.CellToLocal(new Vector3Int(x, min, 0)); vertices[vertex + 1] = gridLayout.CellToLocal(new Vector3Int(x, max, 0)); uvs2[vertex] = new Vector2(0f, 2 * hexOffset); uvs2[vertex + 1] = new Vector2(0f, 2 * hexOffset + drawTotal); vertex += 2; // Alternate Row Offset vertices[vertex] = gridLayout.CellToLocal(new Vector3Int(x, min - 1, 0)); vertices[vertex + 1] = gridLayout.CellToLocal(new Vector3Int(x, max - 1, 0)); uvs2[vertex] = new Vector2(0f, 2 * hexOffset); uvs2[vertex + 1] = new Vector2(0f, 2 * hexOffset + drawTotal); vertex += 2; } // Draw Diagonals for (int y = min; y < max; y++) { float drawDiagOffset = ((y + 1) % 3) * hexOffset; var cellOffSet = Grid.Swizzle(gridLayout.cellSwizzle, new Vector3(0f, y * cellStrideY + cellOffsetY, 0.0f)); // Slope Up vertices[vertex] = gridLayout.CellToLocal(new Vector3Int(Mathf.RoundToInt(1.5f * min), min, 0)) + cellOffSet; vertices[vertex + 1] = gridLayout.CellToLocal(new Vector3Int(Mathf.RoundToInt(1.5f * max), max, 0)) + cellOffSet; uvs2[vertex] = new Vector2(0f, drawDiagOffset); uvs2[vertex + 1] = new Vector2(0f, drawDiagOffset + drawDiagTotal); vertex += 2; // Slope Down vertices[vertex] = gridLayout.CellToLocal(new Vector3Int(Mathf.RoundToInt(1.5f * max), min, 0)) + cellOffSet; vertices[vertex + 1] = gridLayout.CellToLocal(new Vector3Int(Mathf.RoundToInt(1.5f * min), max, 0)) + cellOffSet; uvs2[vertex] = new Vector2(0f, drawDiagOffset); uvs2[vertex + 1] = new Vector2(0f, drawDiagOffset + drawDiagTotal); vertex += 2; // Alternate Row Offset vertices[vertex] = gridLayout.CellToLocal(new Vector3Int(Mathf.RoundToInt(1.5f * min) + 1, min, 0)) + cellOffSet; vertices[vertex + 1] = gridLayout.CellToLocal(new Vector3Int(Mathf.RoundToInt(1.5f * max) + 1, max, 0)) + cellOffSet; uvs2[vertex] = new Vector2(0f, drawDiagOffset); uvs2[vertex + 1] = new Vector2(0f, drawDiagOffset + drawDiagTotal); vertex += 2; vertices[vertex] = gridLayout.CellToLocal(new Vector3Int(Mathf.RoundToInt(1.5f * max) + 1, min, 0)) + cellOffSet; vertices[vertex + 1] = gridLayout.CellToLocal(new Vector3Int(Mathf.RoundToInt(1.5f * min) + 1, max, 0)) + cellOffSet; uvs2[vertex] = new Vector2(0f, drawDiagOffset); uvs2[vertex + 1] = new Vector2(0f, drawDiagOffset + drawDiagTotal); vertex += 2; } var uv0 = new Vector2(k_GridGizmoDistanceFalloff, 0f); var indices = new int[totalVertices]; var uvs = new Vector2[totalVertices]; var colors = new Color[totalVertices]; var normals = new Vector3[totalVertices]; // Normal channel stores the position of the other end point of the line. var uvs3 = new Vector2[totalVertices]; // UV3 channel stores the UV2 value of the other end point of the line. for (int i = 0; i < totalVertices; i++) { uvs[i] = uv0; indices[i] = i; colors[i] = color; var alternate = i + ((i % 2) == 0 ? 1 : -1); normals[i] = vertices[alternate]; uvs3[i] = uvs2[alternate]; } mesh.vertices = vertices; mesh.uv = uvs; mesh.uv2 = uvs2; mesh.uv3 = uvs3; mesh.colors = colors; mesh.normals = normals; mesh.SetIndices(indices, MeshTopology.Lines, 0); return(mesh); }
public static Mesh GenerateCachedGridMesh(GridLayout gridLayout, Color color, float screenPixelSize, RectInt bounds, MeshTopology topology) { Mesh mesh = new Mesh(); mesh.hideFlags = HideFlags.HideAndDontSave; int vertex = 0; int totalVertices = topology == MeshTopology.Quads ? 8 * (bounds.size.x + bounds.size.y) : 4 * (bounds.size.x + bounds.size.y); Vector3 horizontalPixelOffset = new Vector3(screenPixelSize, 0f, 0f); Vector3 verticalPixelOffset = new Vector3(0f, screenPixelSize, 0f); Vector3[] vertices = new Vector3[totalVertices]; Vector2[] uvs2 = new Vector2[totalVertices]; Vector3 cellStride = gridLayout.cellSize + gridLayout.cellGap; Vector3Int minPosition = new Vector3Int(0, bounds.min.y, 0); Vector3Int maxPosition = new Vector3Int(0, bounds.max.y, 0); Vector3 cellGap = Vector3.zero; if (!Mathf.Approximately(cellStride.x, 0f)) { cellGap.x = gridLayout.cellSize.x / cellStride.x; } for (int x = bounds.min.x; x < bounds.max.x; x++) { minPosition.x = x; maxPosition.x = x; vertices[vertex + 0] = gridLayout.CellToLocal(minPosition); vertices[vertex + 1] = gridLayout.CellToLocal(maxPosition); uvs2[vertex + 0] = Vector2.zero; uvs2[vertex + 1] = new Vector2(0f, cellStride.y * bounds.size.y); if (topology == MeshTopology.Quads) { vertices[vertex + 2] = gridLayout.CellToLocal(maxPosition) + horizontalPixelOffset; vertices[vertex + 3] = gridLayout.CellToLocal(minPosition) + horizontalPixelOffset; uvs2[vertex + 2] = new Vector2(0f, cellStride.y * bounds.size.y); uvs2[vertex + 3] = Vector2.zero; } vertex += topology == MeshTopology.Quads ? 4 : 2; vertices[vertex + 0] = gridLayout.CellToLocalInterpolated(minPosition + cellGap); vertices[vertex + 1] = gridLayout.CellToLocalInterpolated(maxPosition + cellGap); uvs2[vertex + 0] = Vector2.zero; uvs2[vertex + 1] = new Vector2(0f, cellStride.y * bounds.size.y); if (topology == MeshTopology.Quads) { vertices[vertex + 2] = gridLayout.CellToLocalInterpolated(maxPosition + cellGap) + horizontalPixelOffset; vertices[vertex + 3] = gridLayout.CellToLocalInterpolated(minPosition + cellGap) + horizontalPixelOffset; uvs2[vertex + 2] = new Vector2(0f, cellStride.y * bounds.size.y); uvs2[vertex + 3] = Vector2.zero; } vertex += topology == MeshTopology.Quads ? 4 : 2; } minPosition = new Vector3Int(bounds.min.x, 0, 0); maxPosition = new Vector3Int(bounds.max.x, 0, 0); cellGap = Vector3.zero; if (!Mathf.Approximately(cellStride.y, 0f)) { cellGap.y = gridLayout.cellSize.y / cellStride.y; } for (int y = bounds.min.y; y < bounds.max.y; y++) { minPosition.y = y; maxPosition.y = y; vertices[vertex + 0] = gridLayout.CellToLocal(minPosition); vertices[vertex + 1] = gridLayout.CellToLocal(maxPosition); uvs2[vertex + 0] = Vector2.zero; uvs2[vertex + 1] = new Vector2(cellStride.x * bounds.size.x, 0f); if (topology == MeshTopology.Quads) { vertices[vertex + 2] = gridLayout.CellToLocal(maxPosition) + verticalPixelOffset; vertices[vertex + 3] = gridLayout.CellToLocal(minPosition) + verticalPixelOffset; uvs2[vertex + 2] = new Vector2(cellStride.x * bounds.size.x, 0f); uvs2[vertex + 3] = Vector2.zero; } vertex += topology == MeshTopology.Quads ? 4 : 2; vertices[vertex + 0] = gridLayout.CellToLocalInterpolated(minPosition + cellGap); vertices[vertex + 1] = gridLayout.CellToLocalInterpolated(maxPosition + cellGap); uvs2[vertex + 0] = Vector2.zero; uvs2[vertex + 1] = new Vector2(cellStride.x * bounds.size.x, 0f); if (topology == MeshTopology.Quads) { vertices[vertex + 2] = gridLayout.CellToLocalInterpolated(maxPosition + cellGap) + verticalPixelOffset; vertices[vertex + 3] = gridLayout.CellToLocalInterpolated(minPosition + cellGap) + verticalPixelOffset; uvs2[vertex + 2] = new Vector2(cellStride.x * bounds.size.x, 0f); uvs2[vertex + 3] = Vector2.zero; } vertex += topology == MeshTopology.Quads ? 4 : 2; } var uv0 = new Vector2(k_GridGizmoDistanceFalloff, 0f); var uvs = new Vector2[vertex]; var indices = new int[vertex]; var colors = new Color[vertex]; var normals = new Vector3[totalVertices]; // Normal channel stores the position of the other end point of the line. var uvs3 = new Vector2[totalVertices]; // UV3 channel stores the UV2 value of the other end point of the line. for (int i = 0; i < vertex; i++) { uvs[i] = uv0; indices[i] = i; colors[i] = color; var alternate = i + ((i % 2) == 0 ? 1 : -1); normals[i] = vertices[alternate]; uvs3[i] = uvs2[alternate]; } mesh.vertices = vertices; mesh.uv = uvs; mesh.uv2 = uvs2; mesh.uv3 = uvs3; mesh.colors = colors; mesh.normals = normals; mesh.SetIndices(indices, topology, 0); return(mesh); }
public override void OnPaintSceneGUI(GridLayout gridLayout, GameObject brushTarget, BoundsInt position, GridBrushBase.Tool tool, bool executing) { Tilemap tilemap = brushTarget.GetComponent <Tilemap>(); if (tilemap != null) { lastTilemap = tilemap; } base.OnPaintSceneGUI(gridLayout, brushTarget, position, tool, executing); switch (sudokuBrush.paintModel) { case PaintModel.SUDOKU: break; case PaintModel.FOUR: var fourZPosition = new Vector3Int(position.min.x, position.min.y, sudokuBrush.z); Vector3[] cellPostions = null; BoundsInt newPosition = new BoundsInt(fourZPosition, position.size); if (gridLayout.cellLayout == GridLayout.CellLayout.Isometric || gridLayout.cellLayout == GridLayout.CellLayout.Isometric) { cellPostions = new Vector3[] { gridLayout.CellToLocal(new Vector3Int(newPosition.max.x - 2, newPosition.max.y - 1, newPosition.max.z)), gridLayout.CellToLocal(new Vector3Int(newPosition.max.x + 0, newPosition.max.y - 1, newPosition.max.z)), gridLayout.CellToLocal(new Vector3Int(newPosition.max.x - 1, newPosition.max.y - 0, newPosition.max.z)), gridLayout.CellToLocal(new Vector3Int(newPosition.max.x - 1, newPosition.max.y - 2, newPosition.max.z)) }; } else { cellPostions = new Vector3[] { gridLayout.CellToLocal(new Vector3Int(newPosition.max.x - 1, newPosition.max.y - 1, newPosition.max.z)), gridLayout.CellToLocal(new Vector3Int(newPosition.max.x + 1, newPosition.max.y - 1, newPosition.max.z)), gridLayout.CellToLocal(new Vector3Int(newPosition.max.x, newPosition.max.y - 0, newPosition.max.z)), gridLayout.CellToLocal(new Vector3Int(newPosition.max.x, newPosition.max.y - 2, newPosition.max.z)) }; } Handles.color = Color.cyan; Handles.DrawLine(cellPostions[0], cellPostions[1]); Handles.color = Color.cyan; Handles.DrawLine(cellPostions[2], cellPostions[3]); break; default: break; } var labelText = "Pos: " + new Vector3Int(position.x, position.y, sudokuBrush.z); if (position.size.x > 1 || position.size.y > 1) { labelText += " Size: " + new Vector2Int(position.size.x, position.size.y); } Handles.Label(gridLayout.CellToWorld(new Vector3Int(position.x, position.y, sudokuBrush.z)), labelText); }