找回密碼
 注冊帳號

掃一掃,訪問微社區

camera.onprecull 在消隱之前

2015-1-4 03:57| 發布者: 楊炎| 查看: 1982| 評論: 0|原作者: 蠻牛|來自: unity3d腳本manual

摘要: camera.onprecull 在消隱之前functioncopyfrom(other:camera) : voiddescription描述onprecull is called before a camera culls the scene.onprecull在相機開始裁剪場景之前調用。culling determines which objects ...

camera.onprecull 在消隱之前

functioncopyfrom(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.fieldofviewor 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 之后確定。

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

void onprecull() {

camera.resetworldtocameramatrix();

camera.resetprojectionmatrix();

camera.projectionmatrix = camera.projectionmatrix *matrix4x4.scale(newvector3(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);

}

相關閱讀

文章點評
相關文章
女校游泳队彩金