Example #1
0
        private float3 GetCellPosition(int x, int y, int z)
        {
            Vector3 position;

            position.x = PositionCalculator.GetPositionX(x, z);
            position.y = PositionCalculator.GetPositionY(y);
            position.z = PositionCalculator.GetPositionZ(z);

            return(new float3(position.x, position.y, position.z));
        }
        void AddTextCoordinatesOnGrid(int width, int height)
        {
            for (int z = 0, i = 0; z < height; z++)
            {
                for (int x = 0; x < width; x++)
                {
                    Text label = Instantiate <Text>(cellLabelPrefab);

                    label.rectTransform.SetParent(gridCanvas.transform, false);
                    label.rectTransform.anchoredPosition = new Vector2(
                        PositionCalculator.GetPositionX(x, z),
                        PositionCalculator.GetPositionZ(z)
                        );

                    HexCoordinates coordinates = CoordinatesService.CreateFromOffset(x, z);
                    label.text = "" + coordinates.Value.x + ", " + coordinates.Value.y + ", " + coordinates.Value.z + "";
                }
            }
        }