# OnRenderObject()

> OnRenderObject is called after camera has rendered the Scene.

## Definition

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

```csharp
public void OnRenderObject()
```

### Remarks

This can be used to render your own objects using [Graphics.RenderMesh](/engine/6000.0/script-reference/unityengine/graphics/rendermesh.md) or other functions. This function is similar to OnPostRender, except OnRenderObject is called on any object that has a script with the function; no matter if it's attached to a Camera or not. You should only use this function to draw and not to change any high level rendering states. **Note**: `OnRenderObject` is called automatically by the Built-in Render Pipeline and Universal Render Piepline (URP) but not by the High-Definition Render Pipeline (HDRP). For equivalent functionality, use [RenderPipelineManager.endCameraRendering](/engine/6000.0/script-reference/unityengine/rendering/renderpipelinemanager/endcamerarendering.md) or a [ScriptableRenderPass](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@latest/index.html?subfolder=/api/UnityEngine.Rendering.Universal.ScriptableRenderPass.html) in URP, or a [Custom Pass](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Custom-Pass.html) in HDRP. Be aware that this function can have a performance impact because it runs on for every GameObject with a script that uses this callback.

### Examples

```csharp

using System.Collections;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public Mesh mainMesh;
    public Mesh miniMapMesh;

    void OnRenderObject()
    {
        // Render different meshes for the object depending on whether
        // the main camera or minimap camera is viewing.
        if (Camera.current.name == "MiniMapcam")
        {
            Graphics.DrawMeshNow(miniMapMesh, transform.position, transform.rotation);
        }
        else
        {
            Graphics.DrawMeshNow(mainMesh, transform.position, transform.rotation);
        }
    }
}
```
