Hello, Im trying to assign some procedurally generated meshes to some entities, so I can manipulate them in ECS.
Ive found RenderMeshUtility examples but my meshes arent rendering, and the MaterialMeshInfo component looks suspicious to me.
Can anyone help me out here?
Code
var entityManager = world.EntityManager;
var ecb = new EntityCommandBuffer(Allocator.Temp);
foreach (Mesh proceduralMesh in fuzzMeshList)
{
// Create a RenderMeshDescription using the convenience constructor
// with named parameters.
var desc = new RenderMeshDescription(
shadowCastingMode: ShadowCastingMode.Off,
receiveShadows: false);
// Create an array of mesh and material required for runtime rendering.
var renderMeshArray = new RenderMeshArray(new Material[] { myGrassMaterial }, new Mesh[] { proceduralMesh });
// Create empty base entity
var prototype = entityManager.CreateEntity();
ecb.AddComponent(prototype, new LocalTransform {Position = new float3(0f,0.1f,0f)});
// Call AddComponents to populate base entity with the components required
// by Entities Graphics
RenderMeshUtility.AddComponents(
prototype,
entityManager,
desc,
renderMeshArray,
MaterialMeshInfo.FromRenderMeshArrayIndices(0, 0));
entityManager.AddComponentData(prototype, new LocalToWorld());
}
ecb.Playback(entityManager);
ecb.Dispose();```
Below is the inspector of one of these entities