Search Unity

Question Looking for somthing similar to .WithChangeFilter<>() but for removed components

Discussion in 'Entity Component System' started by SergeyRomanko, Sep 25, 2020.

  1. SergeyRomanko

    SergeyRomanko

    Joined:
    Oct 18, 2014
    Posts:
    47
    Hello everyone,

    my code is heavily based on reactions for component changes. WithChangeFilter<>() works great for adding and changing components. But it obviously doesn't work for removed components

    Is there a way to detect remove of a component? Maybe something like this

    Code (CSharp):
    1.             Entities
    2.                 .WithAll<Item>()
    3.                 .WithNone<IsActive>()
    4.                 .WithRemoveFilter<IsActive>()
    5.                 .ForEach((int entityInQueryIndex, Entity entity) =>
    6.                 {
    7.                     ....
    8.                 })
    9.                 .WithStructuralChanges()
    10.                 .Run();

    I am aware of ISystemStateComponentData, but I am looking for more elegant solution
     
  2. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    992
  3. SergeyRomanko

    SergeyRomanko

    Joined:
    Oct 18, 2014
    Posts:
    47
    WAYNGames likes this.
  4. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
  5. SergeyRomanko

    SergeyRomanko

    Joined:
    Oct 18, 2014
    Posts:
    47