System concepts
A system provides the logic that transforms component data from its current state to its next state. For example, a system might update the positions of all moving entities by their velocity multiplied by the time interval since the previous update.
A system runs on the main thread once per frame. Systems are organized into a hierarchy of system groups that you can use to organize the order that systems should update in.
You can create either an unmanaged, or a managed system in Entities. To define a managed system, create a class that inherits from SystemBase
. To define an unmanaged system, create a struct that inherits from ISystem
. For more information, see Systems overview.
Both ISystem
and SystemBase
have three methods you can override: OnUpdate
, OnCreate
and OnDestroy
. A system's OnUpdate
method is executed once per frame.
A system can only process entities in one world, so a system is associated with a particular world. You can use the World
property to return the world that the system is attached to.
By default, an automatic bootstrapping process creates an instance of each system and system group. The bootstrapping creates a default world with three system groups: InitializationSystemGroup
, SimulationSystemGroup
, and PresentationSystemGroup
. By default an instance of a system is added to the SimulationSystemGroup
. You can use the [UpdateInGroup]
attribute to override this behavior.
To disable the automatic bootstrapping process, use the scripting define #UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP
.
System types
There are several types of systems you can use:
SystemBase
: Provides a base class for managed systems.ISystem
: Provides an interface for unmanaged systems.EntityCommandBufferSystem
: Provides entity command bufferinstances for other systems. This allows you to group structural changes together to improve the performance of your application.ComponentSystemGroup
: Provides a nested organization and update order for systems.
System groups
A system group can have systems and other system groups as its children. A system group has an update method that you can override, and the base method updates the group's children in a sorted order.
For more information, see the documentation on System groups.
Inspecting systems
You can use the Systems window to inspect the update order of the systems in each world, and to view the full hierarchy of the system groups. For more information, see the documentation on Systems window reference.
Systems in the Editor
In the Editor, the following icons represent the different types of Systems. You’ll see this when you use the specific Entities windows and Inspectors.
Icon | Represents |
---|---|
A system group | |
A system | |
An entity command buffer system set to execute at the beginning of a system group with the OrderFirst argument. | |
An entity command buffer system set to execute at the end of a system group with the OrderLast argument. |