OnPreCullはカメラがシーンのカリングを行う直前に呼び出されます。
カリングはカメラから見えるオブジェクトに対して行われます。OnPreCullはカリングが行われる直前に呼び出されます。 このメッセージはカメラにアタッチされている全てのスクリプトに送られます。 もしカメラの見えている範囲(例: fieldOfView または transform)を変えたい場合に、 このメッセージを使います。シーンオブジェクトの可視性は /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 dont want to affect all other cammeras. function OnPostRender () { GL.SetRevertBackfacing (false); }
using UnityEngine; using System.Collections; public class ExampleClass : 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 ExampleClass(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)