Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Multiple worlds - Any easy way to call all the default systems in correct order?

Discussion in 'Entity Component System and C# Job system' started by PixelMind, Dec 7, 2018.

  1. PixelMind

    PixelMind

    Joined:
    Aug 16, 2013
    Posts:
    100
    I'm trying to run two ecs worlds on one game instance. I figured that I have to create worlds and then call Update() manually on each system. However now that I'm running everything manually, I also seem to lose the default systems running behind the default World. So systems like TransformSystem and MeshInstanceRendererSystem are not updated. Also systems are not visible on entity debugger window when they are updated manually.

    Is there a way to call these "essential" systems automatically? Or hook my worlds to update just like the default world? There's World.Active but that's for a single world.
    Any pointers how this might be best to implement would be appreaciated :)

    Right now I can only think of just going through the codebase and try to figure out when each default system should be run. I have a feeling that this is bound to cause weird bugs if I forget to run something essential. Or if I just run things in wrong order. Especially as the codebase and workflow in general is new to me.

    ----

    To give some context I have a multiplayer game that has completely separated client and server logic running on editor. Physics are separate, packets are sent and received from/to the same machine, etc.
    The point is that I don't have to make a build to run client and server separately which takes ages on HDRP. Separate ECS worlds would keep entities isolated from each other.
     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    686
    You must update ScriptBehaviourUpdateOrder, for default\specific world, or for all worlds:
    ScriptBehaviourUpdateOrder.UpdatePlayerLoop(params World[]);
     
    Last edited: Dec 7, 2018
    rigidbuddy likes this.
  3. PixelMind

    PixelMind

    Joined:
    Aug 16, 2013
    Posts:
    100
    @eizenhorn Excellent, thank you! That was exactly what I was looking for :)

    That also fixed the issue of systems not showing up on debugger.

    ---
    Edit: or maybe not exactly. Default systems still missing... but it could well be a bug on my end.

    Edit2: So yea it did fix the issue. Just had to call CreateManager somewhere for each system which of course makes sense. It's actually better than I wanted since I can disable rendering related systems on server so I can't even accidentally run them there.
     
    Last edited: Dec 7, 2018
  4. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    686
    You use UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP ?

    Show you code where you create second world and update behaviour.
     
  5. PixelMind

    PixelMind

    Joined:
    Aug 16, 2013
    Posts:
    100
    Not at the moment but I may disable it in the future.
    But the previous edit was just an issue that I removed punch of code and forgot to create related managers. Everything renders / works correctly now and I can disable default stuff on server which is nice.

    Thanks again @eizenhorn