public void MarkGrid(string name, Vector3[] coords, Material mat, Color color) { Unmark(name); cellGroups.Add(name, new GameObject(name)); MeshFilter mf = cellGroups[name].AddComponent <MeshFilter>(); MeshRenderer mr = cellGroups[name].AddComponent <MeshRenderer>(); mf.mesh = MeshGen.CreateGridMesh(MeshGen.Hex(HexLayout.instance.wide_width / 2), coords); mf.mesh.name = "GridMesh" + name; //RecalculateMeshHeights(mf.mesh); mf.mesh.RecalculateBounds(); mf.mesh.RecalculateNormals(); mr.material = mat; //tile.GetComponent<MeshRenderer>().sharedMaterial; mr.material.color = color; FindRoot(); cellGroups[name].transform.position = commonParent.position + Vector3.up * 0.01f * cellGroups.Count; cellGroups[name].transform.rotation = commonParent.rotation; cellGroups[name].transform.parent = commonParent; }
///Creates a combined Mesh of squares centered at coords public static Mesh CreateGridMesh(Vector3[] coords) { Mesh mesh = MeshGen.Square(0.5f); return(CreateGridMesh(mesh, coords)); }