Unity3d ECS 动态创建系统

由于需要对System做热更,所以System不能随主程序打包,使用的hybridclr插件编译后需要使用程序集加载的方式进行Dll注入

要执行该操作则需要在代码中进行System的管理 使用的ECS版本

 跟随教程

 设置不让自动初始化的宏

在自己的脚本中

var world = DefaultWorldInitialization.Initialize("Default World", false);

  创建一个世界

 教程中比较奇怪的是,我的TypeManager并没有这些函数

所以得要手动进行系统的创建

  var group = world.GetOrCreateSystemManaged<ComponentSystemGroup>();
  if (group!=null)
  {
     var system = world.CreateSystemManaged<HelloSystem>();
      group.AddSystemToUpdateList(system);
  }

  

group.AddSystemToUpdateList(system);是将系统托管到ComponentSystemGroup组内,否则创建的System将不会进行Update,生命周期也不会受到ECS监管
posted @ 2024-06-26 15:53  AnAng  阅读(3)  评论(0编辑  收藏  举报