Unity ECS 测试Demo

版本:

安装:

Window - PackageManager

 +号点开选择 Add package from git URL 方式依次安装下面的包:

com.unity.entities

com.unity.jobs

com.unity.rendering_hybrid

com.unity.mathematics

另外Burst包可以直接在Package Manager中找到安装1.4.1版本

 目前无论是ComponentSystem还是JobSystem,都被Unity宣布弃用。(不少老教程还在用这两个Class)所以我这里一律会使用SystemBase。

SystemBase的和ComponentSystem和JobSystem的主要区别是,在OnUpdate的Entites.ForEach loop后,必须要选择一个extension method,主要有3个常用的extension method,

1. Run() : Runs the job immediately on the current thread.

2. Schedul(): Adds an IJobEntityBatchWithIndex instance to the job scheduler queue for sequential (non-parallel) execution.

3. ScheduleParallel(): Adds an IJobEntityBatchWithIndex instance to the job scheduler queue for parallel execution.

可能的编译报错:

Add partial keyword to all SystemBase, ISystem, and ISystemBase types

Entities' internal code generation mechanism has changed from IL post-processing to Source Generators. This means you can see the underlying code that the ECS framework generates, and debug it accordingly. You can see this code in your project's /Temp/GeneratedCode folder. Because of this, the generated code must be valid C# and the partial keyword is needed to augment system types.

Unity generates an error for all types of this kind that don't have the appropriate keyword. You can manually add the keyword, or you can use the Editor feature below to automatically add them to all your system types (make sure to save your work before enabling this).

To auto update your project’s systems with this keyword:

  1. Save your project.
  2. Go to DOTS > DOTS Compiler > Add missing partial keyword to systems
  3. Let Unity recompile source files.
  4. Disable the Add missing partial keyword to systems setting

No SRP present, no compute shader support, or running with -nographics. Hybrid Renderer disabled

DOTS 0.5 doesn't support built-in pipeline anymore, so you need to upgrade to URP or HDRP...

Entities installation and setup | Entities | 0.51.0-preview.32

Unity项目技术方案Dots架构方案简介_Peter_Gao_的博客-CSDN博客_dots开发

猜你喜欢

转载自blog.csdn.net/qq_42672770/article/details/125835932