Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Feature Request Better RenderMeshUtility.AddComponents Method

Discussion in 'Graphics for ECS' started by StefanWo, Feb 20, 2023.

  1. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    105
    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?

    Code (CSharp):
    1.        
    2. var renderMeshInfo = MaterialMeshInfo.FromRenderMeshArrayIndices(0, 0, submeshIndex: (sbyte)submeshIndex);
    3.         RenderMeshUtility.AddComponents(entity, EntityManager, desc, renderMesh, renderMeshInfo);
    4.         // Afterwards we resolve it to runtime
    5.         EntityManager.SetComponentData(entity, new MaterialMeshInfo(EntityManager.World.Convert(material), EntityManager.World.Convert(mesh), submeshIndex: (sbyte)submeshIndex));
    6.         EntityManager.RemoveComponent<RenderMeshArray>(entity);
    7.  
     
  2. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    283
    We could add an overload that does not take RenderMeshArray, and expects that the user-provided MaterialMeshInfo contains a valid registered mesh and material.
     
    StefanWo likes this.