Example #1
0
 private void CreateGrid()
 {
     for (int x = 0; x < _gridSizeX; x++)
     {
         for (int z = 0; z < _gridSizeY; z++)
         {
             GameObject newHex = Instantiate(_hexagon, Vector3.zero, Quaternion.identity) as GameObject;
             _hex        = newHex.GetComponent <CalculateHex> ();
             _hex.Radius = _radius;
             _position   = new Vector3((x + z * 0.5f - z / 2) * _hex.Width - _gridSizeX / 2, 0, z * _hex.Height * 0.75f - _gridSizeY / 2);
             newHex.transform.position = _position;
             _hex.CreateHexagon(_position);
         }
     }
 }
Example #2
0
 private void Start()
 {
     _mr = GetComponent <MeshRenderer> ();
     StartCoroutine(ColorSwap());
     _mesh     = GetComponent <MeshFilter> ().mesh;
     _hex      = GetComponent <CalculateHex> ();
     _vertices = _hex.Points;
     Triangulate();
     UVMapping();
     _mesh.Clear();
     _mesh.Optimize();
     _mesh.vertices  = _vertices.ToArray();
     _mesh.triangles = _triangles.ToArray();
     _mesh.uv        = _uvs.ToArray();
     _mesh.RecalculateNormals();
     transform.position = new Vector3(0, 0, 0);
 }