private void ConvertSubmesh(UnityEngine.MeshRenderer uMeshRenderer, MeshFilter uMeshFilter, Entity entity, int subMeshIndex) { UnityEngine.Mesh mesh = uMeshFilter.sharedMesh; //Get all entities on the shared mesh and just use the one with same type as the material var meshEntity = GetPrimaryEntity(mesh); //In Big-U, If there are more materials than sub-meshes, the last submesh will be rendered with each of the remaining materials. List <Material> materials = new List <Material>(); uMeshRenderer.GetSharedMaterials(materials); //If there are less materials than submeshes, just use the last material on the remaining meshrenderers var entityMaterial = GetPrimaryEntity(materials[materials.Count - 1]); if (subMeshIndex < materials.Count) { entityMaterial = GetPrimaryEntity(materials[subMeshIndex]); } DstEntityManager.AddComponentData(entity, new Unity.Tiny.Rendering.MeshRenderer() { material = entityMaterial, startIndex = Convert.ToUInt16(mesh.GetIndexStart(subMeshIndex)), indexCount = Convert.ToUInt16(mesh.GetIndexCount(subMeshIndex)) }); DstEntityManager.AddComponentData(entity, new WorldBounds()); if (DstEntityManager.HasComponent <LitMaterial>(entityMaterial)) { DstEntityManager.AddComponentData(entity, new LitMeshReference() { mesh = meshEntity }); } else if (DstEntityManager.HasComponent <SimpleMaterial>(entityMaterial)) { DstEntityManager.AddComponentData(entity, new SimpleMeshReference() { mesh = meshEntity }); } }