SetComponentEnabled
Enable or disable a IComponentData on the specified Entity. This operation does not cause a structural change, or affect the value of the component. For the purposes of EntityQuery matching, an entity with a disabled component will behave as if it does not have that component.
Read time 2 minutesLast updated a day ago
Definition
- Type: Method
- Namespace: Unity.Entities
- Assembly: UnityEngine.EntitiesModule
SetComponentEnabled<T>(ComponentTypeHandle<T>, int, bool)
Enable or disable a IComponentData on the specified Entity. This operation does not cause a structural change, or affect the value of the component. For the purposes of EntityQuery matching, an entity with a disabled component will behave as if it does not have that component.
public readonly void SetComponentEnabled<T>(ref ComponentTypeHandle<T> typeHandle, int entityIndexInChunk, bool value) where T : struct, IComponentData, IEnableableComponent
Parameters
A type handle for the component type that will be enabled or disabled.
The index within this chunk of the entity whose component should be checked.
True if the specified component should be enabled, or false if it should be disabled.
Remarks
Additional Resources: ArchetypeChunk.IsComponentEnabled
SetComponentEnabled<T>(BufferTypeHandle<T>, int, bool)
Enable or disable a IBufferElementData on the specified Entity. This operation does not cause a structural change, or affect the value of the component. For the purposes of EntityQuery matching, an entity with a disabled component will behave as if it does not have that component.
public readonly void SetComponentEnabled<T>(ref BufferTypeHandle<T> bufferTypeHandle, int entityIndexInChunk, bool value) where T : unmanaged, IBufferElementData, IEnableableComponent
Parameters
A type handle for the buffer component type that will be enabled or disabled.
The index within this chunk of the entity whose buffer component should be checked.
True if the specified buffer component should be enabled, or false if it should be disabled.
Remarks
Additional Resources: ArchetypeChunk.IsComponentEnabled
SetComponentEnabled(DynamicComponentTypeHandle, int, bool)
Enable or disable a IComponentData on the specified Entity. This operation does not cause a structural change, or affect the value of the component. For the purposes of EntityQuery matching, an entity with a disabled component will behave as if it does not have that component.
public readonly void SetComponentEnabled(ref DynamicComponentTypeHandle typeHandle, int entityIndexInChunk, bool value)
Parameters
A type handle for the component type that will be enabled or disabled.
The index within this chunk of the entity whose component should be checked.
True if the specified component should be enabled, or false if it should be disabled.