Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Best way to call EnqueueCallback (without a system)?

Discussion in 'Physics for ECS' started by Mr-Mechanical, Dec 6, 2019.

  1. Mr-Mechanical


    May 31, 2015
    In the some ECS samples I found I've seen EnqueueCallback being called with a system using [UpdateBefore(typeof(StepPhysicsWorld))]. Is there anyway to use EnqueueCallback without using a whole system and [UpdateBefore(typeof(StepPhysicsWorld))]?
  2. steveeHavok


    Mar 19, 2019
    You can call EnqueueCallback wherever you like, however StepPhysicsWorld clears the callback queue after stepping. Using your own system that updates before StepPhysicsWorld ensures that the callbacks are enqueued again before the next step (i.e. before StepPhysicsWorld.OnUpdate).
    If you know you are not going to be changing the callback and are making Unity Physics a local package anyway you might want to think about tweaking com.unity.physics\Unity.Physics\ECS\Systems\StepPhysicsWorld.cs and commenting out the call to
    Mr-Mechanical likes this.