How do you ensure that a JobComponentSystem gets executed before a ComponentSystem?

It seems that a JobComponentSystem doesn’t execute right away. I tried using UpdateBefore but it doesn’t work.

[UpdateBefore(typeof(SystemB))]
class SystemA : JobComponentSystem {
    ...
}

class SystemB : ComponentSystem {
    protected override void OnUpdate() {
        // While debugging, I saw that the data was not yet updated in SystemA
    }
}

Maybe the injects in your SystemA was not satisfied at that frame and it skips the update?

Because systems without injection - disabled. Systems are automatically disabled when all ComponentGroups have zero entities. [AlwaysUpdateSystem] can be used to always force update a system.

Actually system with no injection equals to AlwaysUpdateSystem! (excerpt from ComponentSystemBase)

But with one or more injection defined, if it has zero entity coming then it is automatically disabled. This is correct.

        public bool ShouldRunSystem()
        {
            if (m_AlwaysUpdateSystem)
                return true;

            var length = m_ComponentGroups?.Length ?? 0;

            if (length == 0)
                return true;

            // If all the groups are empty, skip it.
            // (There’s no way to know what they key value is without other markup)
            for (int i = 0;i != length;i++)
            {
                if (!m_ComponentGroups[i].IsEmptyIgnoreFilter)
                    return true;
            }

            return false;
        }
        internal sealed override void InternalUpdate()
        {
            if (Enabled && ShouldRunSystem()) { ...
1 Like

Yes, I’m sorry, sleepwalker incorrectly wrote, I meant exactly zero entities, the system without injecting always work of course.

1 Like

Ok English is difficult… op if you are confused my “injection” meant the presence of [Inject] tag or any first time use of a unique GetComponentGroup but @eizenhorn 's “injection” meant the amount of entities that is coming in as a result of those injection.

  • Injection defined : 0 → Always update
  • Injection defined : 1+ / Entities injected : 0 → Does not update
  • Injection defined : 1+ / Entities injected : 1+ → Updates
  • Injection defined : 1+ / Entities injected : 0 / [AlwaysUpdateSystem] → Always update

So it might be that in your … it decided that the system should not update.

I’ll see if there were no entities injected to SystemA. I’m transforming a ComponentSystem into a JobComponentSystem. The ComponentSystem version works and I didn’t change the injected data.

It’s working now. The job system just had an error. Thus, I don’t see any updates in SystemB.