Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    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:
    124
    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:
    351
    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:
    884
    I have manually registered material and meshes in most cases and it would be great to have this variant of api.
     
    StefanWo likes this.