void CreateCell(int x, int z, int count) { Vector3 position; position.x = (x + z * 0.5f - z / 2) * (Hex.innerRadius * 2f); position.y = 0f; position.z = z * (Hex.outerRadius * 1.5f); HexCell cell = hexCells[count] = Instantiate <HexCell>(cellPrefab); cell.name = "Cell" + x.ToString() + "||" + z.ToString(); // cell.transform.SetParent(transform, false); cell.transform.localPosition = position; cell.hexCoordinates = HexCoordinates.FromOffsetToHexCoordinates(x, z); cell.Index = count; cell.ShaderData = cellShaderData; // Neighboring if (x > 0) { // Connecting from right to left, vice versa cell.SetNeighbor(HexDirection.Left, hexCells[count - 1]); } if (z > 0) { if ((z & 1) == 0) // even number - masking { // Connecting from top-left to down-right, vice versa cell.SetNeighbor(HexDirection.DownRight, hexCells[count - cellCountX]); if (x > 0) { cell.SetNeighbor(HexDirection.DownLeft, hexCells[count - cellCountX - 1]); } } else { cell.SetNeighbor(HexDirection.DownLeft, hexCells[count - cellCountX]); if (x < cellCountX - 1) { cell.SetNeighbor(HexDirection.DownRight, hexCells[count - cellCountX + 1]); } } } Text cellText = Instantiate <Text>(cellTextPrafab); cellText.name = "Text " + x.ToString() + "||" + z.ToString(); // cellText.rectTransform.SetParent(hexCanvas.transform, false); cellText.rectTransform.anchoredPosition = new Vector2(position.x, position.z); // cellText.text = cell.hexCoordinates.ToStringOnSeperateLines(); CHANGE INTO DISTANCE SYSTEM cell.uiRect = cellText.rectTransform; cell.Elevation = 0; AddCellToChunk(x, z, cell); }