void HandleOnCellClick(int cellIndex) { Debug.Log("Clicked cell: " + cellIndex); switch (selectionMode) { case SELECTION_MODE.CUSTOM_PATH: if (selectionState == 0) { firstCell = cellIndex; map.SetCellColor(firstCell, Color.green, true); selectionState = 1; } else { DrawPath(firstCell, cellIndex); selectionState = 0; } break; case SELECTION_MODE.CUSTOM_COST: if (selectionState == 0) { firstCell = cellIndex; map.SetCellColor(firstCell, Color.green, true); selectionState = 1; } else { // Assign crossing cost between previously selected cell and clicked cell map.SetCellNeighbourCost(firstCell, cellIndex, 1000, true); // Draw a line Vector3[] points = map.GetCellSharedEdge(firstCell, cellIndex); if (points != null) { map.ClearCells(true, false, false); map.AddLine(points [0], points [1], Color.yellow, 0, 0, 0.002f, 0); // Switch selection mode back to select first cell } selectionState = 0; } break; } }