Search Unity

How to enable/disable arrays of entities with LinkedEntityGroup?

Discussion in 'Entity Component System' started by daschatten, Sep 20, 2019.

  1. daschatten

    daschatten

    Joined:
    Jul 16, 2015
    Posts:
    208
    Hey,

    within a chunk system i have several NativeArray<Entity> with some entities being the root of a LinkedEntityGroup. I want to enable/disable them if the chunk changes visibility state.

    I found those options:
    • EntityManager.AddComponent: provides batch but doesn't obey LinkedEntityGroup
    • EntityManager.SetEnabled: obeys LinkedEntityGroup but doesn't support batch
    Is there a way to get a batched operation which takes account of LinkedEntityGroup?

    Thanks!
     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    LinkedEntityGroup is buffer. Buffers has AsNativeArray. EntityManager.AddComponent supports native array overload.
     
  3. daschatten

    daschatten

    Joined:
    Jul 16, 2015
    Posts:
    208
    Yep, but that requires a call per entity. There seems to be no recursive method for this, at least i haven't found one.
     
  4. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    559
    you can separate the entities that have LinkedEntityGroup from the ones that don't, and batch vs SetEnabled accordingly.