Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Component dependency problem

Discussion in 'Entity Component System' started by lijianfeng, Apr 10, 2020.

  1. lijianfeng

    lijianfeng

    Joined:
    Sep 8, 2015
    Posts:
    54
    Code (CSharp):
    1.      world = World.DefaultGameObjectInjectionWorld;
    2.         world.EntityManager.CreateEntity(typeof(A ), typeof(C));
    3.         world.EntityManager.CreateEntity(typeof(C),typeof(B));
    4.  
    5.  
    Code (CSharp):
    1. class SystemA : SystemBase
    2. {
    3.     protected override void OnUpdate()
    4.     {
    5.       Entities.ForEach((ref A  value,ref C b) => {
    6.  
    7.       }).ScheduleParallel();
    8.  
    9.     }
    10. }
    Code (CSharp):
    1. class SystemB : SystemBase
    2. {
    3.  
    4.     protected override void OnUpdate()
    5.     {
    6.         Entities.WithoutBurst().ForEach((Entity entity,ref C c, ref B value) =>
    7.         {
    8.         }).ScheduleParallel();
    9.  
    10.     }
    11. }
    Threa are two complete sperate Archtype,So system A and system B can ParallelRun without problem,although they write to the same component C, But now System B depend on System A,:oops:,Will you improve this?
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,223
    Code (CSharp):
    1. EntityManager.CreateEntity(typeof(A), typeof(B), typeof(C));
    Right now the dependency system just has to track two JobHandles per component type. Think about what it would require for it to do what you are asking for. Does that seem feasible to you?