Search Unity

Inquiry on how to properly create a new world

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

  1. Soaryn

    Soaryn

    Joined:
    Apr 17, 2015
    Posts:
    328
    When attempting to make a World dedicated for constructing and then providing batches of entities once constructed, I noticed a slight issue when trying to have this new world update. The idea was to create a world with about three different systems, however when trying to add to the player loop I noticed the default world would no longer update after trying this:
    Code (CSharp):
    1. ScriptBehaviourUpdateOrder.UpdatePlayerLoop(CustomWorld);

    Then I considered, what if the worlds needed to all be re-added, so I tried:
    Code (CSharp):
    1. var worlds = World.AllWorlds;
    2. var worldArray = new World[worlds.Count];
    3. worlds.CopyTo(worldArray, 0);
    4. ScriptBehaviourUpdateOrder.UpdatePlayerLoop(worldArray);
    This oddly enough worked, but more oddly stopped working after a few play/stops of the editor. This also winds up being seemingly overly hacky and also has a few potentials issues outside of the existing "stopped working" issue.

    My question: is there a better way, or more proper way to add a custom world to the player loop?
    Secondary Question: would a sample on the Samples Github for world handling be out of the question at the moment?