void CreateCell(int x, int z, int i) { Vector3 postion; postion.x = (x + z * .5f - z / 2) * (HecMetrics.innerRadius * 2f); postion.y = 0f; postion.z = z * (HecMetrics.outerRadius * 1.5f); HexCell cell = cells[i] = Instantiate <HexCell>(cellPrefab); cell.transform.localPosition = postion; cell.coordinates = HexCoordinates.FromOffesetCoordinates(x, z); cell.Color = defaultColor; if (x > 0) { cell.SetNeighbor(HexDirection.W, cells[i - 1]); } if (z > 0) { if ((z & 1) == 0) { cell.SetNeighbor(HexDirection.SE, cells[i - cellCountX]); if (x > 0) { cell.SetNeighbor(HexDirection.SW, cells[i - cellCountX - 1]); } } else { cell.SetNeighbor(HexDirection.SW, cells[i - cellCountX]); if (x < cellCountX - 1) { cell.SetNeighbor(HexDirection.SE, cells[i - cellCountX + 1]); } } } Text label = Instantiate <Text>(cellLabelPrefab); label.rectTransform.anchoredPosition = new Vector2(postion.x, postion.z); label.text = cell.coordinates.ToStingOnSperateLines(); cell.uiRect = label.rectTransform; cell.Elevation = 0; makeRegion(cell, x, z); AddCellToChunk(x, z, cell); }