// Use this for initialization public void CreateMesh() { filter = GetComponent <MeshFilter>(); mesh = new Mesh(); mesh.vertices = HexHelper.CreateLineStripVertices(HexHelper.getCorners(.5f * scale), thickness / 2.0f); mesh.SetIndices(HexHelper.CreateLineStripIndices(6, true), MeshTopology.Triangles, 0); filter.mesh = mesh; }
void Start() { material = Instantiate(material); material.renderQueue = 2001; material.color = color; List <Tuple <Vector3, Vector3> > edges = new List <Tuple <Vector3, Vector3> >(); foreach (HexTile tile in tiles) { if (tile.isOccluded || tile.type == HexTileType.Disabled) { continue; } foreach (HexPath path in tile.neighbors) { // path is crossing a border if (path.target.type == HexTileType.Disabled || path.target.isOccluded || !tiles.Contains(path.target)) { LineHexagon lineHex = tile.GetComponent <LineHexagon>(); Vector3[] corners = lineHex.worldSpaceCorners; edges.Add(new Tuple <Vector3, Vector3>(corners[path.index], corners[(path.index + 1) % 6])); } } } List <Vector3[]> lineStrips = CreateLineStrips(edges); foreach (Vector3[] lineStrip in lineStrips) { GameObject stripObject = new GameObject("outline"); stripObject.transform.SetParent(transform); stripObject.layer = 14; MeshFilter filter = stripObject.AddComponent <MeshFilter>(); MeshRenderer renderer = stripObject.AddComponent <MeshRenderer>(); renderer.material = material; Mesh mesh = new Mesh(); mesh.vertices = HexHelper.CreateLineStripVertices(lineStrip, thickness / 2.0f); mesh.SetIndices(HexHelper.CreateLineStripIndices(lineStrip.Length, true), MeshTopology.Triangles, 0); filter.mesh = mesh; } }