OnRenderObject is called after camera has rendered the Scene.
This can be used to render your own objects using Graphics.DrawMeshNow 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.
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 or a ScriptableRenderPass in URP, or a Custom Pass in HDRP.
using UnityEngine;
public class Example : MonoBehaviour { Mesh mainMesh; 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); } } }