Esempio n. 1
0
        void CreateCell(int x, int z, int i)
        {
            Vector3 position;

            position.x = (x + z * 0.5f - z / 2) * (HexMetrics.innerRadius * 2f);
            position.y = 0f;
            position.z = z * (HexMetrics.outerRadius * 1.5f);

            HexCell cell = cells[i] = Instantiate <HexCell>(cellPrefab);

            cell.transform.SetParent(transform, false);
            cell.transform.localPosition = position;
            cell.gameObject.name         = "cell " + i;
            cell.coordinates             = HexCoordinates.FromOffsetCoordinates(x, z);

            Text label = Instantiate <Text>(cellLabelPrefab);

            label.rectTransform.SetParent(gridCanvas.transform, false);
            label.rectTransform.anchoredPosition = new Vector2(position.x, position.z);
            label.text            = cell.coordinates.ToStringOnSeparateLines();
            label.gameObject.name = "cellUI " + i;
        }