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
.
#pragma strict // Attach this to a camera. // Inverts the view of the camera so everything rendered by it, is flipped var camera; function Start() { camera = GetComponent.<Camera>(); } function OnPreCull() { camera.ResetWorldToCameraMatrix(); camera.ResetProjectionMatrix(); camera.projectionMatrix = camera.projectionMatrix * Matrix4x4.Scale(new Vector3(1, -1, 1)); } function OnPreRender() { GL.SetRevertBackfacing(true); } function OnPostRender() { GL.SetRevertBackfacing(false); }
// Attach this to a camera. // Inverts the view of the camera so everything rendered by it, is flipped using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { Camera camera;
void Start() { camera = GetComponent<Camera>(); } void OnPreCull() { camera.ResetWorldToCameraMatrix(); camera.ResetProjectionMatrix(); camera.projectionMatrix = camera.projectionMatrix * Matrix4x4.Scale(new Vector3(1, -1, 1)); } void OnPreRender() { GL.SetRevertBackfacing(true); } void OnPostRender() { GL.SetRevertBackfacing(false); } }