# onPostRender

> Delegate that you can use to execute custom code after a Camera renders the scene.

## Definition

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

```csharp
public static Camera.CameraCallback onPostRender
```

### Remarks

In the Built-in Render Pipeline, Unity calls `onPostRender` after any Camera finishes rendering. To execute custom code at this point, create callbacks that match the signature of [Camera.CameraCallback](/engine/6000.6/script-reference/unityengine/camera/cameracallback.md), and add them to this delegate.

For similar functionality that applies only to a single Camera and requires your script to be on the same GameObject, see [MonoBehaviour.OnPostRender()](/engine/6000.6/script-reference/unityengine/monobehaviour/onpostrender.md).

If you're using a Scriptable Render Pipeline, for example the Universal Render Pipeline, use [RenderPipelineManager](/engine/6000.6/script-reference/unityengine/rendering/renderpipelinemanager.md) instead.

To execute code after Unity renders all Cameras and GUI, use [WaitForEndOfFrame](/engine/6000.6/script-reference/unityengine/waitforendofframe.md) or a [CommandBuffer](/engine/6000.6/script-reference/unityengine/rendering/commandbuffer.md).

```csharp
using UnityEngine;

public class CameraCallbackExample : MonoBehaviour
{
    // Add your callback to the delegate's invocation list
    void Start()
    {
        Camera.onPostRender += OnPostRenderCallback;
    }

    // Unity calls the methods in this delegate's invocation list before rendering any camera
    void OnPostRenderCallback(Camera cam)
    {
        Debug.Log("Camera callback: Camera name is " + cam.name);

        // Unity calls this for every active Camera.
        // If you're only interested in a particular Camera,
        // check whether the Camera is the one you're interested in
        if (cam == Camera.main)
        {
            // Put your custom code here
        }
    }

    // Remove your callback from the delegate's invocation list
    void OnDestroy()
    {
        Camera.onPostRender -= OnPostRenderCallback;
    }
}
```

Additional Resources: [Camera.CameraCallback](/engine/6000.6/script-reference/unityengine/camera/cameracallback.md), [Camera.onPreRender](/engine/6000.6/script-reference/unityengine/camera/onprerender-1.md), [Camera.onPreCull](/engine/6000.6/script-reference/unityengine/camera/onprecull-1.md), [MonoBehaviour.OnPostRender()](/engine/6000.6/script-reference/unityengine/monobehaviour/onpostrender.md), [CommandBuffer](/engine/6000.6/script-reference/unityengine/rendering/commandbuffer.md), [Extending the Built-in Render Pipeline using CommandBuffers](/engine/6000.6/manual/render-pipelines/built-in-render-pipeline/graphics-command-buffers/buffers.md), [WaitForEndOfFrame](/engine/6000.6/script-reference/unityengine/waitforendofframe.md).
