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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

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:
    118
    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:
    335
    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.
  3. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    864
    I have manually registered material and meshes in most cases and it would be great to have this variant of api.
     
    StefanWo likes this.