Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Feedback on the new Reactive System

Discussion in 'Data Oriented Technology Stack' started by Vacummus, Aug 2, 2018.

  1. Vacummus

    Vacummus

    Joined:
    Dec 18, 2013
    Posts:
    136
    Been playing around with the Reactive System and really loving it as it provides an ECS approach to event based implementations. The [ChangeFilter] is brilliant and is really easy to work with.

    Now I wish I could say the same thing about the approach for executing on added and removed components. It’s cool that you can use
    ISystemComponetData to make that happen. But it requires some boilerplate code and it would be a lot easier and less confusing if the approach was similar to the [ChangeFilter] attribute, where you can specify [AddedFilter] and [RemovedFilter] for components you wish to execute on when they are added or removed. This would also make the filtering more consistent. And speaking of consistency, it would be cool if there was a [SubtractiveFilter] for components. And if for some reason attributes don’t work with this, then taking the struct/generics approach is fine as well, where you have SubtractiveComponent<T>, ChangedComponet<T>, AddedComponent<T>, RemovedComponet<T>, RequiredComponent<T>, etc. Both approaches are great, but at the end of the day what’s most important is that there is consistency between how you can filter components for a system.
     
  2. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    402
    A very important feature of ISystemComponentData is that it is not removed when the entity is destroyed and allows automatically eg deleting related entities or freeing other related resources. Without this a RemovedComponent wouldn't be possible on entity destruction.
    But a method to handle simple Add/Remove with less code would probably be nice.
     
  3. Fabrice_Lete

    Fabrice_Lete

    Unity Technologies

    Joined:
    May 5, 2018
    Posts:
    25
    There is already [RequireSubtractiveComponent(typeof(...))] that can be used with IJobProcessComponentData, is this what you meant with [SubtractiveFilter]?
     
  4. Vacummus

    Vacummus

    Joined:
    Dec 18, 2013
    Posts:
    136
    Totally, and that's really cool that it allows for that. And a method that encapsulates this would make this better. But even then, that is still inconsistent to how the [ChangedFilter] works. A more simple and consistent approach would make it easier for devs to embrace ECS, especially if the goal here is to democratizing data oriented programming. And I think this totally possible without any performance implications.

    Nice! Yeah, that's along the lines of what I meant, but much better! I was originally thinking that the filter would work in conjunction with the component data you are injecting, kind of like how SubtractiveComponent<T> works today. But what you all have there is way more intuitive since the filter is applied to a IJobProcessComponentData struct and not the data being inject.
     
  5. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    402
    When ISystemComponentData actually carries data, the attribute will not work.

    I guess it would need to add some internal components as Entities without any components probably require alot of special handling and it would need to track exactly which systems knew of the component's existence in the first place as you would want to rely on this feature for your bookkeeping.
     
  6. dthurn

    dthurn

    Joined:
    Feb 17, 2015
    Posts:
    34
    +1 on [AddedFilter]. Getting kind of sick of writing logic like "get all these components and add another tag onto them to indicate this processing step has run"
     
    hippocoder likes this.
  7. rigidbuddy

    rigidbuddy

    Joined:
    Feb 25, 2014
    Posts:
    36
    Found this forum while seeking some sort of messaging system on top of ECS to track add/change/remove component.
    Didn't find a package with Reactive System. Is it in closed beta feature?
     
  8. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,494
    There is no official reactive system. `ISystemStateComponentData` is an ingredient for making that kind of system because before it is not possible to track destroyed entity via injection.

    However one forum user tertle made a generic reactive system out of this system state feature. You might want to check out this thread https://forum.unity.com/threads/i-created-a-reactivecomponentsystem.539581/
     
    rigidbuddy likes this.
  9. rigidbuddy

    rigidbuddy

    Joined:
    Feb 25, 2014
    Posts:
    36
    Thank you! Looks like just what I was looking for
     
  10. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    921
    Wasn't there a video from Unite that went into this a little? I can't seem to find it. I remember seeing something about it somewhere but can't for the life of me find it.
     
  11. Vacummus

    Vacummus

    Joined:
    Dec 18, 2013
    Posts:
    136
    Yeah a little hard to find due to the title, but here it is:

     
    rigidbuddy likes this.
  12. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    604
    How do I use the ChangedFilter in injected struct data? It seems to only work with IJobProcessComponentData.
     
    Lecks likes this.
unityunity