OnPreCull is called before a camera culls the scene.
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 Example : MonoBehaviour { 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); } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): def OnPreCull() as void: camera.ResetWorldToCameraMatrix() camera.ResetProjectionMatrix() camera.projectionMatrix = (camera.projectionMatrix * Matrix4x4.Scale(Vector3(1, -1, 1))) def OnPreRender() as void: GL.SetRevertBackfacing(true) def OnPostRender() as void: GL.SetRevertBackfacing(false)