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 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


    May 24, 2015
    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):
    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);
  2. JussiKnuuttila


    Unity Technologies

    Jun 7, 2019
    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


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