Search Unity

SetFilter not working with RequireForUpdate

Discussion in 'Entity Component System' started by nttLIVE, Jan 23, 2019.

  1. nttLIVE

    nttLIVE

    Joined:
    Sep 13, 2018
    Posts:
    80
    I've updated to the new ECS package and started refactoring some systems to use the RequireForUpdate. I've noticed that the systems are now ignoring the Filters of the componentGroups.

    Anyone else can confirm? I'm also wondering if Filters will be deprecated as well.
     
  2. foxnne

    foxnne

    Joined:
    Apr 18, 2016
    Posts:
    59
    Cant confirm, but the new samples do use SetFilter so I would think it wouldn't be deprecated soon since they don't seem to use Injection or the other things they said were soon to be deprecated in the new samples...
     
  3. nttLIVE

    nttLIVE

    Joined:
    Sep 13, 2018
    Posts:
    80
    Actually, it's even more odd.

    Here I assign my componentGroups and add the RequireForUpdates.
    Code (CSharp):
    1.     ComponentGroup group1;
    2.     ComponentGroup group2;
    3.  
    4.     protected override void OnCreateManager()
    5.     {
    6.         group1= GetComponentGroup(new ComponentType[] {
    7.          COMPONENTS
    8.         });
    9.         RequireForUpdate(group1);
    10.  
    11.         group2= GetComponentGroup(new ComponentType[] {
    12.          COMPONENTS
    13.         });
    14.         group2.SetFilter(FILTER1, FILTER2);
    15.         RequireForUpdate(group2);
    16.     }
    The group2.CalculateLength will be at 0 but it will still trigger an OnUpdate. It seems like the system believes the ComponentGroup is not empty because it does not take into consideration the filters but when the Update happens the filters are applied and the Length of the componentGroup is set to 0.

    Essentially do a CalculateLength == 0 and early return to fix this but I'm not sure if this is the intended behaviour.
     
    Last edited: Jan 23, 2019