Search Unity

Question How to use shared components in parallel job?

Discussion in 'Entity Component System' started by Zylkowski_a, Jul 9, 2020.

  1. Zylkowski_a

    Zylkowski_a

    Joined:
    Jul 27, 2019
    Posts:
    157
    Can I somehow parallelize job on each entity with same sharedComponent?
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    No, you can't use shared components in burst job. They are for grouping entities, not for working on.

    Some advice for learning ecs. Forget you ever learnt what a shared component was. Come back to it when you are confident writing ecs and want to optimise stuff.
     
  3. Zylkowski_a

    Zylkowski_a

    Joined:
    Jul 27, 2019
    Posts:
    157
    Yeah I know shared component shouldn't be used unless it's really needed but I need to deal with RuleTile(like here) entities and I can't see way without them for storing meshes and tiling rules(2D array)
     
  4. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    One of the biggest mistakes people make early is thinking that everything has to be an entity and work in the ecs world. There's no reason that your world data, except maybe a pointer, needs to be stored in an entity. And if the only way you can do it is a shared component, then this is the definitely the wrong way to do it.

    Joachim made a great post about this just a day ago

    https://forum.unity.com/threads/why-vanilla-ecs-is-not-enough.928287/