Search Unity

Toggling RenderMesh

Discussion in 'Graphics for ECS' started by jdtec, Feb 15, 2019.

  1. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    302
    Is there a fast way to toggle if a RenderMesh is active/in-active per entity other than adding and removing the shared component RenderMesh or rewriting my own version of RenderMesh?

    I have thousands of selectable objects. These selectable objects each have a RenderMesh highlight graphic being toggled while a selection box is being dragged over the screen.

    It doesn't feel right to add/remove SharedComponents in large numbers from frame to frame in this situation?
     
    Last edited: Feb 15, 2019
  2. digitaliliad

    digitaliliad

    Joined:
    Jul 1, 2018
    Posts:
    64
    I'm curious, would the Disabled component be applicable, here?
     
  3. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    302
    Thanks, that does work. So instead of Add/Remove RenderMesh I can Add/Remove a Disabled tag component.

    Is adding/removing tag components a reasonable thing to do in this situation? Do you know more of what is going on behind the scenes when this is done in terms of memory layout?
     
  4. digitaliliad

    digitaliliad

    Joined:
    Jul 1, 2018
    Posts:
    64
    From my limited understanding, the Disabled component will keep the affected entity away from the RenderSystem and TransformSystem. Adding any component will necessarily change the entity's archetype, I believe.
     
  5. learc83

    learc83

    Joined:
    Feb 28, 2018
    Posts:
    41
    If I remember correctly, they are planning to make it so that adding tag components (components with no data) doesn't require changing its archetype.