Search Unity

Question How to use AddJobHandleForProducer() in burst compiled ISystem

Discussion in 'Entity Component System' started by pbhogan, Mar 14, 2023.

  1. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    I'm struggling figure out how to use EntityCommandBufferSystem.AddJobHandleForProducer() from within an ISystem that is burst compiled.

    I'm creating Entity Command Buffers like so:

    var singleton = SystemAPI.GetSingleton<EndSimulationEntityCommandBufferSystem.Singleton>();
    var ecb = singleton.CreateCommandBuffer( state.WorldUnmanaged );

    ... and passing ecb into a job.

    But it doesn't seem like there's any way to get a reference to the EntityCommandBufferSystem itself since it's a managed system.

    So, how do we register the JobHandle as a dependency of the ECB system?
     
  2. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    You dont need to, with getting the singleton now.
     
  3. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    Thanks, great to know—is this documented somewhere officially?
     
  4. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    Last edited: Sep 5, 2023
    Ksanone likes this.