Why is ISystem not updated?

It is created. But then , never updated.
But shouldn’t it be executed once a frame even if nothing is found in the query and there’s no requirement set explicitly in the OnCreate? Maybe the entities show up later, right?
I understand that’s because the Query on the creation does not return anything?

    [UpdateInWorld(blabla.Client)]
    [UpdateInGroup(typeof(myGroup))]
    public partial struct TestSystem: ISystem
    {
        private EntityQuery query;

        public void OnCreate(ref SystemState state)
        {
            Debug.Log("Created in world " + state.World.ToString());

            query = SystemAPI.QueryBuilder().WithPresent<IDComponent>().Build();
        }

        public void OnUpdate(ref SystemState state)
        {
            int numIds = query.CalculateEntityCount();
            if(numIds > 20)
                return;
            Debug.Log(string.Format("CLIENT System Update. Num IDs: {0}", numIds));
        }

        public void OnDestroy(ref SystemState state)
        {
        }

There’s another system that creates the entities. The logs appear before the creation of the previous system, so the entities exist at the moment of the other system’s creation.

[UpdateInWorld(....Client)]
public partial struct TestCreationSystem: ISystem
{
    public void OnCreate(ref SystemState state)
    {
        for(uint i = 0; i < 10; i++)
        {
            var entity = state.EntityManager.CreateEntity();
            state.EntityManager.AddComponent<IDComponent>(entity);
            state.EntityManager.SetComponentData(entity, new IDComponent() { Value = i});

            Debug.Log("Created entity with id in Client: " + i);
        }
    }
...

Usage of “UpdateInWorld” suggests you’re using versions of entities packages prior to the base 1.0 release (not recommended if you can help it). Systems in these versions used defined queries as restrictions for the system updating, you’ll need to use AlwaysUpdateSystemAttribute to force updates. You really should try to update to 1.2.4 though if on a compatible Unity release.

I use 1.2.3. But that UpdateInWorld is ours, sorry about that, so maybe that’s something important to note. I’ll try that Update attribute you mention.

The software I’m working on grabs systems with that attribute and adds them to the worlds.

The system is in the world where those entities are. Why isn’t it being updated? Is the query found mandatory to return something in order to update?

Query creation shouldn’t affect anything without a RequireForUpdate/RequireAnyForUpdate call. Try making a system with the same custom attribute etc. but no query and a log in the update. If that doesn’t update, it’s most likely a flaw in whatever your custom update control mechanism is.

You can manually create systems and attach them to appropriate system groups (required step, as runtime-created systems aren’t automatically attached to their UpdateInGroup group) in each world you create. Perhaps you’re doing something along these lines and not actually attaching the system to any group. Check the system inspector and see if the group for that particular world contains the given system. Note that this view only shows systems in the 3 default root groups (initialization/simulation/presentation).

Ah. I found a possible reason. It is the update group I was adding it to.

It has code that prevens calling base.Update() if a particular condition wasn’t true.

 public partial class MyGroup : ComponentSystemGroup 
 {
     protected override void OnUpdate()
     {
         if (condition....)
             return;
         
         base.OnUpdate();
     }
 }

So yeah, that’s why. :frowning: