Class ComponentSystem
An abstract class to implement in order to create a system.
Inherited Members
Namespace: Unity.Entities
Syntax
public abstract class ComponentSystem : ComponentSystemBase
Remarks
Implement a ComponentSystem subclass for systems that perform their work on the main thread or that use Jobs not specifically optimized for ECS. To use the ECS-specific Jobs, such as IJobForEach<T0> or IJobChunk, implement JobComponentSystem instead.
Properties
Entities
This system's query builder object.
Declaration
protected EntityQueryBuilder Entities { get; }
Property Value
Type | Description |
---|---|
EntityQueryBuilder | Use to select and iterate over entities. |
PostUpdateCommands
This system's EntityCommandBuffer.
Declaration
public EntityCommandBuffer PostUpdateCommands { get; }
Property Value
Type | Description |
---|---|
EntityCommandBuffer | A queue of entity-related commands to playback after the system's update function finishes. |
Remarks
When iterating over a collection of entities with Entities, the system prohibits structural changes that would invalidate that collection. Such changes include creating and destroying entities, adding or removing components, and changing the value of shared components.
Instead, add structural change commands to this PostUpdateCommands command buffer. The system executes commands added to this command buffer in order after this system's OnUpdate() function returns.
Methods
InitEntityQueryCache(Int32)
Initializes this system's internal cache of EntityQuery objects to the specified number of queries.
Declaration
protected void InitEntityQueryCache(int cacheSize)
Parameters
Type | Name | Description |
---|---|---|
Int32 | cacheSize | The initial capacity of the system's EntityQuery array. |
Remarks
A system's entity query cache expands automatically as you add additional queries. However, initializing the cache to the correct size when you initialize a system is more efficient and avoids unnecessary, garbage-collected memory allocations.
OnUpdate()
Implement OnUpdate to perform the major work of this system.
Declaration
protected abstract void OnUpdate()
Remarks
The system invokes OnUpdate once per frame on the main thread when any of this system's EntityQueries match existing entities, or if the system has the AlwaysUpdateSystemAttribute.
See Also
Update()
Declaration
public override sealed void Update()