# Constant

> GraphicsBuffer can be used as a constant buffer (uniform buffer).

## Definition

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

```csharp
Constant = 512
```

### Remarks

If you use this target, you can use the [GraphicsBuffer](/engine/6000.6/script-reference/unityengine/graphicsbuffer.md) as a parameter to [ComputeShader.SetConstantBuffer](/engine/6000.6/script-reference/unityengine/computeshader/setconstantbuffer.md) and [Material.SetConstantBuffer](/engine/6000.6/script-reference/unityengine/material/setconstantbuffer.md).

If you also need the buffer to be bound as a structured buffer, you must add the [GraphicsBuffer.Target.Structured](/engine/6000.6/script-reference/unityengine/graphicsbuffer/target/structured.md) flag. Some renderers (such as DX11) do not support binding buffers as both constant and structured buffers.

The data layout of a shader's constant buffer may be different depending on the graphics API. This means [ComputeShader.SetConstantBuffer](/engine/6000.6/script-reference/unityengine/computeshader/setconstantbuffer.md) or [Material.SetConstantBuffer](/engine/6000.6/script-reference/unityengine/material/setconstantbuffer.md) might overwrite data or set variables to the wrong values. See [Writing shaders for different graphics APIs](/engine/6000.6/manual/materials-and-shaders/shaders/writing-custom/shader-writing/sl/writing-shader-writing-shader-programs-hlsl/sl-platform-differences.md) for more information.
