OnPreCull вызывается до того, как камера отсечёт сцену.
Отсечение определяет, какие объекты будут видны в камере. OnPreCull вызывается прямо перед
этим процессом. Это сообщение посылается на все скрипты, прикрепленные к камере.
Если вы хотите изменить параметры просмотра камеры (e.g. fieldOfView или просто transform),
это то место, где можно это сделать. Видимость объектов сцены будет определяться на основе
параметров камеры после OnPreCull.
See Also: onPreCull delegate.
// 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)); } // Set it to true so we can watch the flipped Objects void OnPreRender() { GL.SetRevertBackfacing(true); } // Set it to false again because we dont want to affect all other cammeras. void OnPostRender() { GL.SetRevertBackfacing(false); } }