Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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:
    132
    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:
    352
    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:
    889
    I have manually registered material and meshes in most cases and it would be great to have this variant of api.
     
    StefanWo likes this.