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 move systems from one world to another?

Discussion in 'Entity Component System' started by HeyZoos, Jun 12, 2021.

  1. HeyZoos

    HeyZoos

    Joined:
    Jul 31, 2016
    Posts:
    50
    This code fails to compile, `system` is of type `System.Type` and the method expects a `ComponentSystemBase`. Is there anyway to move systems from one world to another?

    Code (CSharp):
    1.     public class NetworkingBootstrap : MonoBehaviour
    2.     {
    3.         private void Start()
    4.         {
    5.             var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);
    6.             var group = Bootstrap.ServerWorld.GetOrCreateSystem<FixedStepSimulationSystemGroup>();
    7.             var dotsnavGroup = Bootstrap.ServerWorld.GetOrCreateSystem<DotsNavSystemGroup>();
    8.             group.AddSystemToUpdateList(dotsnavGroup);
    9.  
    10.             foreach (var system in systems)
    11.             {
    12.                 if (system.Namespace == null) continue;
    13.                
    14.                 if (system.Namespace.Contains("Path"))
    15.                 {
    16.                     dotsnavGroup.AddSystemToUpdateList((ComponentSystemBase)system);
    17.                 }
    18.             }
    19.         }
    20.     }
     
  2. HeyZoos

    HeyZoos

    Joined:
    Jul 31, 2016
    Posts:
    50
    GetOrCreateSystem(system)