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. Dismiss Notice

How to Specify System to run on Custom World?

Discussion in 'Entity Component System' started by Dapeos, Aug 3, 2020.

  1. Dapeos

    Dapeos

    Joined:
    Jun 27, 2013
    Posts:
    28
    I created a staging world to assist with loading many runtime-configured entities.

    What annotation do I use or how do I specify that I want a system to run on my custom world only?

    I tried [WorldSystemFilter] with no success. When I look in the entity browser and change world to "staging" the systems tab is always empty.

    Thanks,
    Marc
     
  2. Scorr

    Scorr

    Joined:
    Jul 2, 2013
    Posts:
    73
    You can create your own UpdateInWorldAttribute with your own WorldType enum, then wherever you add your systems check the attribute to inject them into the correct world.
     
  3. Dapeos

    Dapeos

    Joined:
    Jun 27, 2013
    Posts:
    28
    Thank Scorr,
    Can you point me to any examples?
    Thanks,
    Marc
     
  4. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    288
    Ok i have some experience with this.

    First:

    create a new world:

    var newWorld = new World("custom world");

    now add some systems to the newWorld:

    newWorld.AddSystemsToRootLevelSystemGroups(types)

    Thats it. You now need to tick these worlds manually (what iam doing), or you need add them to the current game loop, but i dont know how its done in the new api