# TryGetBuffer

> Retrieves the buffer components associated with the specified Entity, if it exists. Then reports if the instance still refers to a valid entity and that it has a buffer component of type T.

## Definition

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

## TryGetBuffer(Entity, DynamicBuffer\<T>)

Retrieves the buffer components associated with the specified [Entity](/engine/7000.0/script-reference/unity/entities/entity.md), if it exists. Then reports if the instance still refers to a valid entity and that it has a buffer component of type T.

```csharp
public bool TryGetBuffer(Entity entity, out DynamicBuffer<T> bufferData)
```

### Parameters

**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The entity.**** (\[DynamicBuffer\<T>]\(/engine/7000.0/script-reference/unity/entities/dynamicbuffer1)): The buffer component of type T for the given entity, if it exists.

### Returns

| Type                                                          | Description                                                                    |
| ------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the entity has a buffer component of type T, and false if it does not. |

## TryGetBuffer(Entity, DynamicBuffer\<T>, bool)

Retrieves the buffer components associated with the specified [Entity](/engine/7000.0/script-reference/unity/entities/entity.md), if it exists. Then reports if the instance still refers to a valid entity and that it has a buffer component of type T.

```csharp
public bool TryGetBuffer(Entity entity, out DynamicBuffer<T> bufferData, out bool entityExists)
```

### Parameters

**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The entity.**** (\[DynamicBuffer\<T>]\(/engine/7000.0/script-reference/unity/entities/dynamicbuffer1)): The buffer component of type T for the given entity, if it exists.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Denotes whether the given entity exists. Use to distinguish entity non-existence from buffer non-existence.

### Returns

| Type                                                          | Description                                                                    |
| ------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the entity has a buffer component of type T, and false if it does not. |
