Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.


Suggest a change


Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.


Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.



Switch to Manual


OnPreCull is called before a camera culls the scene.

Culling determines which objects are visible to the camera. OnPreCull is called just before this process.

This function is called only if the script is attached to the camera and is enabled.

If you want to change camera's viewing parameters (e.g. fieldOfView or just transform), this is the place to do it. Visibility of scene objects will be determined based on camera's parameters after OnPreCull.

	// Attach this to a camera.
	// Inverts the vie of the camera so everything rendered by it, is flipped
	// This will only work on  Unity - PRO
	function OnPreCull () {
		camera.ResetWorldToCameraMatrix ();
		camera.ResetProjectionMatrix ();
		camera.projectionMatrix = camera.projectionMatrix * Matrix4x4.Scale(Vector3 (1, -1, 1));
	// Set it to true so we can watch the flipped Objects
	function OnPreRender () {
		GL.SetRevertBackfacing (true);
	// Set it to false again because we don't want to affect all other cameras.
	function OnPostRender () {
		GL.SetRevertBackfacing (false);
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void OnPreCull() {
        camera.projectionMatrix = camera.projectionMatrix * Matrix4x4.Scale(new Vector3(1, -1, 1));
    void OnPreRender() {
    void OnPostRender() {
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def OnPreCull() as void:
		camera.projectionMatrix = (camera.projectionMatrix * Matrix4x4.Scale(Vector3(1, -1, 1)))

	def OnPreRender() as void:

	def OnPostRender() as void: