MonoBehaviour.OnPreCull 当消隐之前

function OnPreCull () : void

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.

消隐决定哪个物体对于相机来说是可见的.OnPreCull仅是在这个过程被调用。

This function is called only if the script is attached to the camera and is enabled.

只有脚本被附加到相机上时才会调用这个函数。

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.

如果你想改变相机的参数(比如:fieldOfView或者transform),可以在这里做这些。场景物体的可见性将根据相机的参数在OnPreCull之后确定。

using UnityEngine;
using System.Collections;

public class example : 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);
	}
}
// 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
// 把这个赋给相机.所有被它渲染的物体都被翻转.他只在pro版的Unity中有效.
function OnPreCull () {
	camera.ResetWorldToCameraMatrix ();
	camera.ResetProjectionMatrix ();
	amera.projectionMatrix = camera.projectionMatrix * Matrix4x4.Scale ( Vector3 (1, -1, 1));
}
// Set it to true so we can watch the flipped Objects
// 设置它为true以便我们可以看到翻转的物体
function OnPreRender () {
	GL.SetRevertBackfacing (true);
}

// Set it to false again because we don't want to affect all other cameras.
// 再设置它为false,因为我们不想作用于每个相机.
function OnPostRender () {
	GL.SetRevertBackfacing (false);
}
Page last updated: 2011-1-2