ドキュメント

Unity Engine

Download Unity

Unity Engine

onPostRender

Delegate that you can use to execute custom code after a Camera renders the scene.
読み終わるまでの所要時間 2 分最終更新 5日前

Definition

  • Type: Field
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
注意
Deprecated. Camera.onPostRender is deprecated now that the Built-In Render Pipeline is removed. Unity will stop calling it in a later version. To run code after a Camera renders, add a delegate to RenderPipelineManager.endCameraRendering instead. #from(7000.0)
public static Camera.CameraCallback onPostRender

Remarks

onPostRender
is deprecated because the Built-In Render Pipeline is removed. Unity will stop calling it in a future version. 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, 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().
If you're using a Scriptable Render Pipeline, for example the Universal Render Pipeline, use RenderPipelineManager instead.
To execute code after Unity renders all Cameras and GUI, use WaitForEndOfFrame or a CommandBuffer.
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; }}