Camera.OnPreCull 在消隐之前

function CopyFrom (other : Camera) : void

Description描述

OnPreCull is called before a camera culls the scene.

OnPreCull在相机开始裁剪场景之前调用。

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.

裁剪决定哪个物体对于相机来说是可见的。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.

如果你想改变相机的视觉参数(例如: fieldOfView 或者仅仅是变换),就在这里做这个,场景物体的可见性将基于相机的参数在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 仅工作在Unity专业版



function OnPreCull () {

	camera.ResetWorldToCameraMatrix ();

	camera.ResetProjectionMatrix ();

	camera.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 dont want to affect all other cammeras.

//设置为false,因为不想影响所有其他相机

function OnPostRender () {

	GL.SetRevertBackfacing (false);

}
Page last updated: 2011-3-7