SuperAPI AI 工具集

unity-ecs-dots

编程与开发

查看项目

更新于 10-16 01:37

技能介绍

用途:面向 Unity 6 的 ECS/DOTS 开发指南,基于 Unity 6.3 LTS(6000.3),涉及 Entities 1.3、Burst 1.8 与 Jobs 包,用于以面向数据方式构建高性能游戏逻辑。

主要能力:讲解 ECS 与 MonoBehaviour 的差异(Entity 为轻量 ID、组件为无托管结构体、逻辑放在 System、按 archetype 分 chunk 存储、可并行);介绍 IComponentData、ISharedComponentData、IBufferElementData、ICleanupComponentData、IEnableableComponent 与 Tag 组件;Baking 与 SubScene 工作流及 TransformUsageFlags;ISystem(推荐,可 Burst)与 SystemBase;SystemGroup 更新顺序与 UpdateInGroup/Before/After;SystemAPI 查询与单例访问;EntityCommandBuffer 延迟结构变更;Aspects;IJobEntity、IJobChunk 与 Run/Schedule/ScheduleParallel;Burst 编译限制;Unity.Mathematics 替代 Mathf/Vector3;并列出常见反模式与 API 速查。

使用方式:在 SubScene 中放置 ECS 对象,用 Baker 将 authoring 数据烘焙为组件;系统用 partial struct 实现 ISystem 并加 [BurstCompile],通过 SystemAPI.Query 迭代,结构变更走 ECB,并行任务用 EntityCommandBuffer.ParallelWriter 与 sortKey。

适用场景:需要大量实体、缓存友好迭代与多线程性能的 Unity 项目。

限制:Burst 代码不支持托管类型、分配、try/catch、虚方法与可变静态字段;迭代中不可做结构变更;频繁修改 SharedComponentData 会触发 chunk 移动;EntityManager 结构变更仅限主线程。具体安装命令与版本细节资料未提供。