HelloCube:ForEach

This example demonstrates a simple ECS system, which can be rotated by a cube.

It shows what?

This example demonstrates the separation of data and functions of the ECS.
Data stored in the module, and the function is written to the system.
RotationSpeedSystem_ForEach stored in RotationSpeed_ForEach assembly data to update the rotation object.

ComponentSystems和Entities.ForEach

RotationSpeedSystem_ForEach is a ComponentSystem, it uses Entities.ForEach delegate to traverse entities.
This example creates only a single entity, but if added to a scene more entities, the entities RotationSpeedSystem_ForEach updates all - as long as they have RotationSpeed_ForEach assembly (and added when the rotation assembly GameObject convert the ECS component Transform).
Please note that Entities.ForEach of ComponentSystems run on the main thread.
To take advantage of multiple cores, you may be used JobComponentSystem (as a HelloCube illustrated example).

Entity to convert from GameObject

ConvertToEntity MonoBehaviour at wake converting GameObject entity and its child nodes ECS assembly.
Currently, ConvertToEntity built Unity MonoBehaviours set can be converted include Transform and MeshRenderer.
You can use the entity Debugger (menu: Window > Analysis > Entity debuggers ) to examine ECS entities and components of the conversion created.
You can implement IConvertGameObjectEntity interfaces on their MonoBehaviours, to provide ConvertToEntity for converting the data stored in the MonoBehavi for ECS components of the transfer function.
In this example, RotationSpeedAuthoring_ForEach MonoBehaviour IConvertGameObjectEntity used to add components to the entity RotationSpeed_ForEach conversion.

Guess you like

Origin www.cnblogs.com/longsl/p/11324206.html