Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Influence Over System Creation Order

Discussion in 'Entity Component System' started by orionburcham, Jan 22, 2019.

  1. orionburcham

    orionburcham

    Joined:
    Jan 31, 2010
    Posts:
    488
    Do we have any control over the order in which systems are created?

    We have control over the System update order with attributes like [UpdateBefore()], [UpdateAfter()], [UpdateInGroup()]. Is there an equivalent for system creation order? Or would we need to manually control system creation to do that?

    Thanks!
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    Not really. The default setup just gets all types in the assembly, filters them and then iterates creating 1 at a time.

    I'm not actually sure how gettypes order is determined, but in theory there might be a way to name[space] your systems to ensure a specific order but that seems extremely hacky.

    If you have get or create manager in on manager created, it'll create that manager at that point which might be ahead of time but still not really giving you a lot of control.

    I'm not sure controlling system order will be something unity supports because systems are usually considered independent, but maybe when they redo the ordering mess they'll might incidentally add it.

    I personally don't control order, but I do create all the systems myself with zenject. This way I can inject factories and other helpers between systems that might need to be setup beforehand without having to worry about system ordering.