Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

MonoBehaviour.OnPreCull()

マニュアルに切り替える

説明

OnPreCull はカメラがシーンをカリングする前に呼び出されます

カリングはオブジェクトがカメラから見えるかどうかを決めます。OnPreCull はこの処理の前に 呼び出されます。

この関数は、この関数が記述されたスクリプトに Camera がアタッチされていて有効である場合のみ呼び出されます。

カメラの表示パラメーターを変更したい場合に(例えば、fieldOfView や Transform )、 変更を行うために最適なのはこの 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 camera;

void Start() { camera = GetComponent<Camera>(); } 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); } }