Version: 2018.2

Description

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 message is sent to all scripts attached to the camera.

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.

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 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; } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961