public override void OnGUI( Rect position, SerializedProperty property, GUIContent label) { HexCordinates cordinate = new HexCordinates( property.FindPropertyRelative("x").intValue, property.FindPropertyRelative("z").intValue ); position = EditorGUI.PrefixLabel(position, label); GUI.Label(position, cordinate.ToString()); }
void CreateCell(int x, int z, int i) { Vector3 pos; pos.x = (x + z * 0.5f - z / 2) * (HexMetrics.innerRadius * 2f); pos.y = 0f; pos.z = z * (HexMetrics.outerRadius * 1.5f); HexCell cell = cells [i] = Instantiate <HexCell> (cellPrefab); cell.transform.SetParent(transform, false); cell.transform.localPosition = pos; cell.coordinates = HexCordinates.FromOffsetCordinates(x, z); cell.color = defaultColor; cell.cell_index = cell.coordinates.X + cell.coordinates.Z * width + cell.coordinates.Z / 2; gridcolor.setTestLayout(cell); if (x > 0) { cell.SetNeighbor(HexDirection.W, cells [i - 1]); } if (z > 0) { if ((z & 1) == 0) { cell.SetNeighbor(HexDirection.SE, cells [i - width]); if (x > 0) { cell.SetNeighbor(HexDirection.SW, cells [i - width - 1]); } } else { cell.SetNeighbor(HexDirection.SW, cells[i - width]); if (x < width - 1) { cell.SetNeighbor(HexDirection.SE, cells [i - width + 1]); } } } Text label = Instantiate <Text> (cellLabelPrefab); label.rectTransform.SetParent(gridCanvas.transform, false); label.rectTransform.anchoredPosition = new Vector2(pos.x, pos.z); label.text = cell.cell_index.ToString(); }