Better RenderMeshUtility.AddComponents Method

Current its very complicated to use this when i want runtime data. I have to do something like this.
Would be great to have a method to just pass mesh, material and submeshIndex instead of that big sharedC component array.

It seems the only method, that is available to use on runtime, to add something to an entity, correct?

var renderMeshInfo = MaterialMeshInfo.FromRenderMeshArrayIndices(0, 0, submeshIndex: (sbyte)submeshIndex);
        RenderMeshUtility.AddComponents(entity, EntityManager, desc, renderMesh, renderMeshInfo);
        // Afterwards we resolve it to runtime
        EntityManager.SetComponentData(entity, new MaterialMeshInfo(EntityManager.World.Convert(material), EntityManager.World.Convert(mesh), submeshIndex: (sbyte)submeshIndex));
        EntityManager.RemoveComponent<RenderMeshArray>(entity);

We could add an overload that does not take RenderMeshArray, and expects that the user-provided MaterialMeshInfo contains a valid registered mesh and material.

1 Like

I have manually registered material and meshes in most cases and it would be great to have this variant of api.

1 Like