# WriteBuffer

> Write data into the memory buffer allocated by the context.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.LightTransport](/engine/6000.6/script-reference/unityengine/lighttransport.md)
* **Assembly:** UnityEngine.CoreModule

## WriteBuffer\<T>(BufferSlice\<T>, NativeArray\<T>)

Write data into the memory buffer allocated by the context.

```csharp
public void WriteBuffer<T>(BufferSlice<T> dst, NativeArray<T> src) where T : struct
```

### Parameters

**** (\[BufferSlice\<T>]\(/engine/6000.6/script-reference/unityengine/lighttransport/bufferslice1)): The [BufferSlice](/engine/6000.6/script-reference/unityengine/lighttransport/bufferslice1.md) to write to.**** (\[NativeArray\<T>]\(/engine/6000.6/script-reference/unity/collections/nativearray1)): The array in the CPU memory that should be written to the buffer. The array must remain valid until the write operation is complete.

### Remarks

The [ReferenceContext](/engine/6000.6/script-reference/unityengine/lighttransport/referencecontext.md) implementation of the [ReferenceContext.WriteBuffer](/engine/6000.6/script-reference/unityengine/lighttransport/referencecontext/writebuffer.md) method is blocking and returns immediately after writing data into the underlying NativeArray.

**Note:** [EventID](/engine/6000.6/script-reference/unityengine/lighttransport/eventid.md) is single-use. Once an [EventID](/engine/6000.6/script-reference/unityengine/lighttransport/eventid.md) has been passed to this function, it may not be passed to subsequent [IDeviceContext.WriteBuffer](/engine/6000.6/script-reference/unityengine/lighttransport/idevicecontext/writebuffer.md) or [IDeviceContext.ReadBuffer](/engine/6000.6/script-reference/unityengine/lighttransport/idevicecontext/readbuffer.md) calls. Doing so will result in undefined behavior.

## WriteBuffer\<T>(BufferSlice\<T>, NativeArray\<T>, EventID)

Write data into the memory buffer allocated by the context.

```csharp
public void WriteBuffer<T>(BufferSlice<T> dst, NativeArray<T> src, EventID id) where T : struct
```

### Parameters

**** (\[BufferSlice\<T>]\(/engine/6000.6/script-reference/unityengine/lighttransport/bufferslice1)): The [BufferSlice](/engine/6000.6/script-reference/unityengine/lighttransport/bufferslice1.md) to write to.**** (\[NativeArray\<T>]\(/engine/6000.6/script-reference/unity/collections/nativearray1)): The array in the CPU memory that should be written to the buffer. The array must remain valid until the write operation is complete.**** (\[EventID]\(/engine/6000.6/script-reference/unityengine/lighttransport/eventid)): The ID of the event to use to track completion of the write.

### Remarks

The [ReferenceContext](/engine/6000.6/script-reference/unityengine/lighttransport/referencecontext.md) implementation of the [ReferenceContext.WriteBuffer](/engine/6000.6/script-reference/unityengine/lighttransport/referencecontext/writebuffer.md) method is blocking and returns immediately after writing data into the underlying NativeArray.

**Note:** [EventID](/engine/6000.6/script-reference/unityengine/lighttransport/eventid.md) is single-use. Once an [EventID](/engine/6000.6/script-reference/unityengine/lighttransport/eventid.md) has been passed to this function, it may not be passed to subsequent [IDeviceContext.WriteBuffer](/engine/6000.6/script-reference/unityengine/lighttransport/idevicecontext/writebuffer.md) or [IDeviceContext.ReadBuffer](/engine/6000.6/script-reference/unityengine/lighttransport/idevicecontext/readbuffer.md) calls. Doing so will result in undefined behavior.
