# SetBufferCounterValue

> Adds a command to set the counter value of append/consume buffer.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.Rendering](/engine/6000.0/script-reference/unityengine/rendering.md)
* **Assembly:** UnityEngine.CoreModule

## SetBufferCounterValue(ComputeBuffer, uint)

Adds a command to set the counter value of append/consume buffer.

```csharp
public void SetBufferCounterValue(ComputeBuffer buffer, uint counterValue)
```

### Parameters

**** (\[ComputeBuffer]\(/engine/6000.0/script-reference/unityengine/computebuffer)): The destination buffer.**** (\[uint]\(https\://learn.microsoft.com/dotnet/api/system.uint32)): Value of the append/consume counter.

### Remarks

Append/consume and counter buffers (see [ComputeBufferType.Append](/engine/6000.0/script-reference/unityengine/computebuffertype/append.md), [ComputeBufferType.Counter](/engine/6000.0/script-reference/unityengine/computebuffertype/counter.md)) keep track of the number of elements in them with a special counter variable. SetCounterValue explicitly sets the counter value.

This can be used to reset the counter or to set it to a specific value.

Note: SetCounterValue can not be called while the buffer is bound via [CommandBuffer.SetRandomWriteTarget](/engine/6000.0/script-reference/unityengine/rendering/commandbuffer/setrandomwritetarget.md).

## SetBufferCounterValue(GraphicsBuffer, uint)

Adds a command to set the counter value of append/consume buffer.

```csharp
public void SetBufferCounterValue(GraphicsBuffer buffer, uint counterValue)
```

### Parameters

**** (\[GraphicsBuffer]\(/engine/6000.0/script-reference/unityengine/graphicsbuffer)): The destination buffer.**** (\[uint]\(https\://learn.microsoft.com/dotnet/api/system.uint32)): Value of the append/consume counter.

### Remarks

Append/consume and counter buffers (see [ComputeBufferType.Append](/engine/6000.0/script-reference/unityengine/computebuffertype/append.md), [ComputeBufferType.Counter](/engine/6000.0/script-reference/unityengine/computebuffertype/counter.md)) keep track of the number of elements in them with a special counter variable. SetCounterValue explicitly sets the counter value.

This can be used to reset the counter or to set it to a specific value.

Note: SetCounterValue can not be called while the buffer is bound via [CommandBuffer.SetRandomWriteTarget](/engine/6000.0/script-reference/unityengine/rendering/commandbuffer/setrandomwritetarget.md).
