public IEnumerator Draw() { while (true) { foreach (Transform t in transform) { Destroy(t.gameObject); } foreach (Mesh msh in itm.ExtractMeshes()) { GameObject go = new GameObject("testMesh", new Type[] { typeof(MeshFilter), typeof(MeshRenderer) }); go.GetComponent <MeshFilter>().mesh = msh; go.GetComponent <MeshRenderer>().material = mat; go.transform.SetParent(transform, false); } yield return(new WaitForSeconds(0.5f)); } }
public void TestOptimize() { IndexedTriangleMesh itm = new IndexedTriangleMesh(); Vector3[] vectors = new Vector3[] { new Vector3(1, 0, 1), new Vector3(1, 0, -1), new Vector3(-1, 0, -1), new Vector3(-1, 0, 1), new Vector3(0, 0, 0) }; IndexedTriangleMesh.Triangle[] trg = new IndexedTriangleMesh.Triangle[] { new IndexedTriangleMesh.Triangle(new Vector3[] { vectors[0], vectors[1], vectors[4] }), new IndexedTriangleMesh.Triangle(new Vector3[] { vectors[1], vectors[2], vectors[4] }), new IndexedTriangleMesh.Triangle(new Vector3[] { vectors[2], vectors[3], vectors[4] }), new IndexedTriangleMesh.Triangle(new Vector3[] { vectors[3], vectors[0], vectors[4] }) }; foreach (IndexedTriangleMesh.Triangle trig in trg) { itm.AddTriangleByReference(trig); } //Act itm.OptimizeMesh(); //Assert //The object has a new name Mesh testM = itm.ExtractMeshes().First(); NUnit.Framework.Assert.AreEqual(4, testM.vertexCount, "Mesh was not optimized"); }