OnPreCull is called before a camera culls the Scene.
剔除操作决定了摄像机能够看到哪些对象。OnPreCull 在该过程即将开始前
调用。该消息将发送到附加到摄像机的所有脚本。
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
.
另请参阅:onPreCull 委托。
// 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 cam;
void Start() { cam = GetComponent<Camera>(); }
void OnPreCull() { cam.ResetWorldToCameraMatrix(); cam.ResetProjectionMatrix(); cam.projectionMatrix = cam.projectionMatrix * Matrix4x4.Scale(new Vector3(1, -1, 1)); }
// Set it to true so we can watch the flipped Objects void OnPreRender() { GL.invertCulling = true; }
// Set it to false again because we dont want to affect all other cammeras. void OnPostRender() { GL.invertCulling = false; } }