private void MeshDone(SimpleMesh mesh) { Mesh m = mesh.CreateMesh(); MeshRenderer r = GetComponent<MeshRenderer>(); if (mesh.Submeshes.Count > 0) { r.materials = mesh.Submeshes.Select(me => me.RenderMaterial).ToArray(); } else { r.material = mesh.RenderMaterial; } filter.sharedMesh = m; MeshCollider collider = (MeshCollider)this.collider; if(collider != null) collider.sharedMesh = m; }
public void ChunkRecieved(SimpleMesh mesh) { MeshCollider collider = (MeshCollider)this.collider; Mesh oldmesh = filter.sharedMesh; filter.sharedMesh = null; collider.sharedMesh = null; if (oldmesh != null) Mesh.Destroy(oldmesh); Mesh m = mesh.CreateMesh(); MeshRenderer r = GetComponent<MeshRenderer>(); if(mesh.Submeshes.Count > 0) { r.sharedMaterials = mesh.Submeshes.Select(me => me.RenderMaterial).ToArray(); } else { r.sharedMaterial = mesh.RenderMaterial; } filter.sharedMesh = m; collider.sharedMesh = m; }