# ComponentType

> A struct to define a component including how it's accessed and what type of component it is

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule
* **Implements:** [IEquatable\<ComponentType>](https://learn.microsoft.com/dotnet/api/system.iequatable-1), [IComparable\<ComponentType>](https://learn.microsoft.com/dotnet/api/system.icomparable-1)

```csharp
public struct ComponentType : IEquatable<ComponentType>, IComparable<ComponentType>
```

## Fields

| Value                                                                                            | Description                                 |
| ------------------------------------------------------------------------------------------------ | ------------------------------------------- |
| [AccessModeType](/engine/7000.0/script-reference/unity/entities/componenttype/accessmodetype.md) | The way the component type will be accessed |
| [TypeIndex](/engine/7000.0/script-reference/unity/entities/componenttype/typeindex.md)           | A unique index of the component type        |

## Constructors

| Constructor                                                                                                                                | Description             |
| ------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------- |
| [ComponentType(System.Type,Unity.Entities.ComponentType.AccessMode)](/engine/7000.0/script-reference/unity/entities/componenttype/ctor.md) | Create a component type |

## Properties

| Property                                                                                                             | Description                                                                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [HasEntityReferences](/engine/7000.0/script-reference/unity/entities/componenttype/hasentityreferences.md)           | True if any of the fields in the component type are type [Entity](/engine/7000.0/script-reference/unity/entities/entity.md)                                                                                                                                          |
| [HasNativeContainer](/engine/7000.0/script-reference/unity/entities/componenttype/hasnativecontainer.md)             | The component type contains a NativeContainerAttribute decorated member. NativeContainer members found in nested member types will also cause this property to return true.                                                                                          |
| [IsBuffer](/engine/7000.0/script-reference/unity/entities/componenttype/isbuffer.md)                                 | True if the component type is a [IBufferElementData](/engine/7000.0/script-reference/unity/entities/ibufferelementdata.md)                                                                                                                                           |
| [IsChunkComponent](/engine/7000.0/script-reference/unity/entities/componenttype/ischunkcomponent.md)                 | True if the component type is flagged as a chunk component type                                                                                                                                                                                                      |
| [IsChunkSerializable](/engine/7000.0/script-reference/unity/entities/componenttype/ischunkserializable.md)           | True if the component type is appropriate for chunk serialization. Such types are blittable without containing pointer types or have been decorated with [ChunkSerializableAttribute](/engine/7000.0/script-reference/unity/entities/chunkserializableattribute.md). |
| [IsCleanupBufferComponent](/engine/7000.0/script-reference/unity/entities/componenttype/iscleanupbuffercomponent.md) | Bitflag set for component types inheriting from [ICleanupBufferElementData](/engine/7000.0/script-reference/unity/entities/icleanupbufferelementdata.md).                                                                                                            |
| [IsCleanupComponent](/engine/7000.0/script-reference/unity/entities/componenttype/iscleanupcomponent.md)             | True if the component type is a [ICleanupComponentData](/engine/7000.0/script-reference/unity/entities/icleanupcomponentdata.md)                                                                                                                                     |
| [IsCleanupSharedComponent](/engine/7000.0/script-reference/unity/entities/componenttype/iscleanupsharedcomponent.md) | True if the component type is a [ICleanupSharedComponentData](/engine/7000.0/script-reference/unity/entities/icleanupsharedcomponentdata.md)                                                                                                                         |
| [IsComponent](/engine/7000.0/script-reference/unity/entities/componenttype/iscomponent.md)                           | True if the component type is a [IComponentData](/engine/7000.0/script-reference/unity/entities/icomponentdata.md)                                                                                                                                                   |
| [IsEnableable](/engine/7000.0/script-reference/unity/entities/componenttype/isenableable.md)                         | True if the component type is a [IEnableableComponent](/engine/7000.0/script-reference/unity/entities/ienableablecomponent.md)                                                                                                                                       |
| [IsSharedComponent](/engine/7000.0/script-reference/unity/entities/componenttype/issharedcomponent.md)               | True if the component type is a [ISharedComponentData](/engine/7000.0/script-reference/unity/entities/isharedcomponentdata.md)                                                                                                                                       |
| [IsZeroSized](/engine/7000.0/script-reference/unity/entities/componenttype/iszerosized.md)                           | True if the component type does not contain actual fields or data                                                                                                                                                                                                    |

## Methods

| Method                                                                                           | Description                                                                                                                                          |
| ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| [CompareTo](/engine/7000.0/script-reference/unity/entities/componenttype/compareto.md)           | Returns the sort order this component type compared to another                                                                                       |
| [Equals](/engine/7000.0/script-reference/unity/entities/componenttype/equals.md)                 | Checks to see if an object is equal to this component type.                                                                                          |
| [GetHashCode](/engine/7000.0/script-reference/unity/entities/componenttype/gethashcode.md)       | A hash used for comparisons.                                                                                                                         |
| [GetManagedType](/engine/7000.0/script-reference/unity/entities/componenttype/getmanagedtype.md) | Gets the managed Type based on the component's [ComponentType.TypeIndex](/engine/7000.0/script-reference/unity/entities/componenttype/typeindex.md). |
| [ToFixedString](/engine/7000.0/script-reference/unity/entities/componenttype/tofixedstring.md)   | Returns a fixed string of the component type                                                                                                         |
| [ToString](/engine/7000.0/script-reference/unity/entities/componenttype/tostring.md)             | Returns a managed string of the component type                                                                                                       |

## Static Methods

| Method                                                                                                           | Description                                                                                                                                                                                                                                                             |
| ---------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [ChunkComponent](/engine/7000.0/script-reference/unity/entities/componenttype/chunkcomponent.md)                 | Returns a [ComponentType](/engine/7000.0/script-reference/unity/entities/componenttype.md) that is a chunk component with [ComponentType.AccessMode.ReadWrite](/engine/7000.0/script-reference/unity/entities/componenttype/accessmode/readwrite.md) based on the type. |
| [ChunkComponentExclude](/engine/7000.0/script-reference/unity/entities/componenttype/chunkcomponentexclude.md)   | Returns a [ComponentType](/engine/7000.0/script-reference/unity/entities/componenttype.md) that is a chunk component with [ComponentType.AccessMode.Exclude](/engine/7000.0/script-reference/unity/entities/componenttype/accessmode/exclude.md) based on the type.     |
| [ChunkComponentReadOnly](/engine/7000.0/script-reference/unity/entities/componenttype/chunkcomponentreadonly.md) | Returns a [ComponentType](/engine/7000.0/script-reference/unity/entities/componenttype.md) that is a chunk component with [ComponentType.AccessMode.ReadOnly](/engine/7000.0/script-reference/unity/entities/componenttype/accessmode/readonly.md) based on the type.   |
| [Combine](/engine/7000.0/script-reference/unity/entities/componenttype/combine.md)                               | Combine multiple array of component type into one. Duplicate types are removed. It will allocate an array containing all component type. Useful for creating queries during initialization of systems.                                                                  |
| [Exclude](/engine/7000.0/script-reference/unity/entities/componenttype/exclude.md)                               | Returns a [ComponentType](/engine/7000.0/script-reference/unity/entities/componenttype.md) with [ComponentType.AccessMode.Exclude](/engine/7000.0/script-reference/unity/entities/componenttype/accessmode/exclude.md) based on the type.                               |
| [FromTypeIndex](/engine/7000.0/script-reference/unity/entities/componenttype/fromtypeindex.md)                   | Returns a [ComponentType](/engine/7000.0/script-reference/unity/entities/componenttype.md) with [ComponentType.AccessMode.ReadWrite](/engine/7000.0/script-reference/unity/entities/componenttype/accessmode/readwrite.md) based on the typeIndex                       |
| [ReadOnly](/engine/7000.0/script-reference/unity/entities/componenttype/readonly.md)                             | Returns a [ComponentType](/engine/7000.0/script-reference/unity/entities/componenttype.md) with [ComponentType.AccessMode.ReadOnly](/engine/7000.0/script-reference/unity/entities/componenttype/accessmode/readonly.md) based on the type.                             |
| [ReadWrite](/engine/7000.0/script-reference/unity/entities/componenttype/readwrite.md)                           | Returns a [ComponentType](/engine/7000.0/script-reference/unity/entities/componenttype.md) with [ComponentType.AccessMode.ReadWrite](/engine/7000.0/script-reference/unity/entities/componenttype/accessmode/readwrite.md) based on the type.                           |

## Operators

| Operator                                                                                     | Description                                                                                                                                                                                                                                                                               |
| -------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [operator ==](/engine/7000.0/script-reference/unity/entities/componenttype/op-equality.md)   | Evaluates if two component types are equal based on [ComponentType.TypeIndex](/engine/7000.0/script-reference/unity/entities/componenttype/typeindex.md) and [ComponentType.AccessModeType](/engine/7000.0/script-reference/unity/entities/componenttype/accessmodetype.md).              |
| [operator >](/engine/7000.0/script-reference/unity/entities/componenttype/op-greaterthan.md) | Evaluates if one component type is greater than the the other.                                                                                                                                                                                                                            |
| [ComponentType](/engine/7000.0/script-reference/unity/entities/componenttype/op-implicit.md) | Creates a new component type based on the type passed in                                                                                                                                                                                                                                  |
| [operator !=](/engine/7000.0/script-reference/unity/entities/componenttype/op-inequality.md) | Evaluates if two component types are not equal based on [ComponentType.TypeIndex](/engine/7000.0/script-reference/unity/entities/componenttype/typeindex.md) and [ComponentType.AccessModeType](/engine/7000.0/script-reference/unity/entities/componenttype/accessmodetype.md).          |
| [operator \<](/engine/7000.0/script-reference/unity/entities/componenttype/op-lessthan.md)   | Evaluates if one component type is less than the the other first by [ComponentType.TypeIndex](/engine/7000.0/script-reference/unity/entities/componenttype/typeindex.md), then by [ComponentType.AccessMode](/engine/7000.0/script-reference/unity/entities/componenttype/accessmode.md). |

## Enums

| Enum                                                                                                   | Description                      |
| ------------------------------------------------------------------------------------------------------ | -------------------------------- |
| [ComponentType.AccessMode](/engine/7000.0/script-reference/unity/entities/componenttype/accessmode.md) | The access of the component type |
