Unity DOTS System and SystemGroup Overview

Recently, DOTS has finally released an official version. Let’s share the following key concepts of System in DOTS to facilitate everyone to learn and master Unity DOTS development.

Yes, there is a . I hope everyone can click in to exchange development experiences together!

System is the logic code that iteratively calculates and processes the Component Data data of the Entity entities in the World. The code corresponding to System runs on the main thread. All Systems in the World are managed through SystemGroup, and the iteration order of each System is determined through SystemGroup.

System is divided into two modes: managed objects and unmanaged objects. When defining a managed object System, define a class that inherits from SystemBase. When defining an unmanaged object, define a struct that inherits from ISystem.

System has three commonly used interfaces that can be rewritten by users. The interfaces include the following:

Each System can only iterate the Entity in the World where it is located. When each System is created, there will be a data member World pointing to the World where it is located. We can obtain it through the system instance.World.

When Unity runs, a World will be created by default, and a default SystemGroup will be created. They are:

At the same time, all current System classes will be scanned, and an instance will be created for each System class and placed in the SystemGroup. After running, the System will be iteratively calculated. The System created by default will be created in the SimulationSystemGroup group by default if you do not specify a group. If the System needs to be created in a specific group, you can use the attribute decorator [UpdateInGroup].

If you don’t want the system to create it by default, you can define a macro to turn it off:

UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP

System has the following types, which can be used by developers. The types are as follows:

SystemBase: System based on managed classes;

ISystem: System based on unmanaged classes;

EntityComponentBufferSystem: Provides entity command buffers for other systems;

ComponentSystemGroup: The hierarchical relationship of nested System and the order of Update;

Each SystemGroup can contain System and sub-SystemGroups, and the iteration order of System can be determined by overriding the update of SystemGroup. You can view all System and hierarchical relationships of the current system through System Window, as shown in the following figure:

Today’s sharing is here, follow us and learn more about the latest Unity DOTS advanced and practical knowledge.

Guess you like

Origin blog.csdn.net/voidinit/article/details/133910650