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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Best way to create a group of systems that must only be updated manually?

Discussion in 'Entity Component System' started by PhilSA, Dec 1, 2019.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I have a a group of systems that I wish to update manually, and they should never update automatically every frame. They are systems that must launch jobs that filter some results after some other systems have run, so they may be updated anywhere from 0 to 10+ times every frame

    What would be the best approach for this? Right now I'm thinking I'll have a ComponentSystemGroup that these systems will register in. But how do I tell this ComponentSystemGroup to never update by itself?

    Would there be anything wrong with doing this (Enabled = false):


    If I call Update() on a disabled group, will all job dependency and GetArchetypeChunkComponentType(), etc..... still work exactly as expected?

    And am I right in assuming that a system registered in a Disabled group will also be disabled?
     
    Last edited: Dec 1, 2019
  2. Jimmy_Lin

    Jimmy_Lin

    Joined:
    May 8, 2015
    Posts:
    10
  3. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I can't really make use of [UpdateBefore] and [UpdateAfter], since they won't just update once in the frame.

    As for [DisableAutoCreation], I'm in a situation where people might want to add custom systems to the "HitProcessingGroup", and I'd prefer if they don't have to remember to add [DisableAutoCreation] on their systems and create these systems manually on Start. I'd prefer things to be completely automatic when you register your system in HitProcessingGroup, which is why I'm wondering if the "Enabled = false" approach would work

    EDIT: oh snap, I forgot I could add [DisableAutoCreation] on the group itself. If I do that and I manually create that group on start:
    • Will that automatically create all of its child systems as well?
    • Will it make it so that it doesn't receive automatic Update()s?
     
  4. Jimmy_Lin

    Jimmy_Lin

    Joined:
    May 8, 2015
    Posts:
    10
    20191202023250.png 20191202023305.png 20191202023321.png
    I see the official code from the multiple player demo(NetCube)
    You can test it..
     
    PhilSA likes this.