Interface ISystemStateComponentData
An interface for a component type that stores system-specific data.
Namespace: Unity.Entities
Syntax
public interface ISystemStateComponentData : IComponentData
Remarks
ISystemStateComponentData implementations are subject to the same constraints as IComponentData: they can only contain blittable data types.
System state components are specialized components designed to allow systems to store their own stateful data on an entity. The functional difference between a general-purpose component and a system state component is that the presence of a system state component delays entity destruction until the system explicitly removes the component. This delay allows a system to cleanup any state or persistent resources it has created and associated with an entity.
The typical pattern for using a system state component is for the system to find new entities by querying for entities with specific archetype, that do not have the component. The system can add a system state component to the entity and then set state values or create resources for the new entity. A system can then detect entity destruction by querying for entities that have the system state component, but not the other components in the original archetype. The system must then cleanup any state or resources and then remove the system state component. The ECS code only fully deletes the entity after the system removes the system state component.
See System State Components for additional information.