# 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.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

## SetComponentEnabled\<T>(ComponentTypeHandle\<T>, int, bool)

Enable or disable a [IComponentData](/engine/7000.0/script-reference/unity/entities/icomponentdata.md) on the specified [Entity](/engine/7000.0/script-reference/unity/entities/entity.md). 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.

```csharp
public readonly void SetComponentEnabled<T>(ref ComponentTypeHandle<T> typeHandle, int entityIndexInChunk, bool value) where T : struct, IComponentData, IEnableableComponent
```

### Parameters

**** (\[ComponentTypeHandle\<T>]\(/engine/7000.0/script-reference/unity/entities/componenttypehandle1)): A type handle for the component type that will be enabled or disabled.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index within this chunk of the entity whose component should be checked.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): True if the specified component should be enabled, or false if it should be disabled.

### Remarks

Additional Resources: [ArchetypeChunk.IsComponentEnabled](/engine/7000.0/script-reference/unity/entities/archetypechunk/iscomponentenabled.md)

## SetComponentEnabled\<T>(BufferTypeHandle\<T>, int, bool)

Enable or disable a [IBufferElementData](/engine/7000.0/script-reference/unity/entities/ibufferelementdata.md) on the specified [Entity](/engine/7000.0/script-reference/unity/entities/entity.md). 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.

```csharp
public readonly void SetComponentEnabled<T>(ref BufferTypeHandle<T> bufferTypeHandle, int entityIndexInChunk, bool value) where T : unmanaged, IBufferElementData, IEnableableComponent
```

### Parameters

**** (\[BufferTypeHandle\<T>]\(/engine/7000.0/script-reference/unity/entities/buffertypehandle1)): A type handle for the buffer component type that will be enabled or disabled.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index within this chunk of the entity whose buffer component should be checked.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): True if the specified buffer component should be enabled, or false if it should be disabled.

### Remarks

Additional Resources: [ArchetypeChunk.IsComponentEnabled](/engine/7000.0/script-reference/unity/entities/archetypechunk/iscomponentenabled.md)

## SetComponentEnabled(DynamicComponentTypeHandle, int, bool)

Enable or disable a [IComponentData](/engine/7000.0/script-reference/unity/entities/icomponentdata.md) on the specified [Entity](/engine/7000.0/script-reference/unity/entities/entity.md). 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.

```csharp
public readonly void SetComponentEnabled(ref DynamicComponentTypeHandle typeHandle, int entityIndexInChunk, bool value)
```

### Parameters

**** (\[DynamicComponentTypeHandle]\(/engine/7000.0/script-reference/unity/entities/dynamiccomponenttypehandle)): A type handle for the component type that will be enabled or disabled.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index within this chunk of the entity whose component should be checked.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): True if the specified component should be enabled, or false if it should be disabled.
