Method CreateSystemManaged
CreateSystemManaged<T>()
Create and return an instance of a system of type T
in this World.
Declaration
public T CreateSystemManaged<T>() where T : ComponentSystemBase, new()
Returns
Type | Description |
---|---|
T | The new instance of system type |
Type Parameters
Name | Description |
---|---|
T | The system type |
Remarks
This can result in multiple instances of the same system in a single World, which is generally undesirable.
Important: This function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before creating the system, and no additional Jobs can start before the function is finished. A sync point can cause a drop in performance because the ECS framework may not be able to make use of the processing power of all available cores.
Note: This system reference is not guaranteed to be safe to use. If the system or world is destroyed then the OnDestroy and cleanup functionality will have been called for this system.
If possible, using CreateSystem(Type) is preferred, and instead of public member data, component data is recommended for system level data that needs to be shared between systems or externally to them. This defines a data protocol for the system which is separated from the system functionality.
Private member data which is only used internally to the system is recommended.
Keep in mind using a managed reference for systems
- encourages coupling of data and functionality
- couples data to the system type with no direct path to decouple
- does not provide lifetime or thread safety guarantees for data access
- does not provide lifetime or thread safety guarantees for system access through the returned managed reference
If T
has not been registered with the TypeManager, this method will register it before adding the system.
CreateSystemManaged(Type)
Create and return an instance of a system of type type
in this World.
Declaration
public ComponentSystemBase CreateSystemManaged(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The system type |
Returns
Type | Description |
---|---|
ComponentSystemBase | The new instance of system type |
Remarks
This can result in multiple instances of the same system in a single World, which is generally undesirable.
Important: This function creates a sync point, which means that the EntityManager waits for all currently running Jobs to complete before creating the system, and no additional Jobs can start before the function is finished. A sync point can cause a drop in performance because the ECS framework may not be able to make use of the processing power of all available cores.
Note: This system reference is not guaranteed to be safe to use. If the system or world is destroyed then the OnDestroy and cleanup functionality will have been called for this system.
If possible, using CreateSystem(Type) is preferred, and instead of public member data, component data is recommended for system level data that needs to be shared between systems or externally to them. This defines a data protocol for the system which is separated from the system functionality.
Private member data which is only used internally to the system is recommended.
Keep in mind using a managed reference for systems
- encourages coupling of data and functionality
- couples data to the system type with no direct path to decouple
- does not provide lifetime or thread safety guarantees for data access
- does not provide lifetime or thread safety guarantees for system access through the returned managed reference
CreateSystemManaged(SystemTypeIndex)
Create and return an instance of a system of type type
in this World.
Declaration
public ComponentSystemBase CreateSystemManaged(SystemTypeIndex type)
Parameters
Type | Name | Description |
---|---|---|
SystemTypeIndex | type | The system type |
Returns
Type | Description |
---|---|
ComponentSystemBase | The new instance of system type |