找回密碼
 注冊帳號

掃一掃,訪問微社區

camera.screenpointtoray 屏幕位置轉射線

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

摘要: camera.screenpointtoray 屏幕位置轉射線functionscreenpointtoray(position:raydescription描述returns a ray going from camera through a screen point.返回一條射線從攝像機通過一個屏幕點。resulting ray is in ...

camera.screenpointtoray 屏幕位置轉射線

functionscreenpointtoray(position:ray

description描述

returns a ray going from camera through a screen point.

返回一條射線從攝像機通過一個屏幕點。

resulting ray is in world space, starting on the near plane of the camera and going through position's (x,y) pixel coordinates on the screen (position.z is ignored).

產生的射線是在世界空間中,從相機的近裁剪面開始并穿過屏幕position(x,y)像素坐標(position.z被忽略)。

screenspace is defined in pixels. the bottom-left of the screen is (0,0); the right-top is (pixelwidth,pixelheight).

屏幕空間以像素定義。屏幕的左下為(0,0);右上是(pixelwidth,pixelheight)。

c#

javascript

using unityengine;

using system.collections;

public class example : monobehaviour {

void update() {

ray ray = camera.screenpointtoray(new vector3(200, 200, 0));

debug.drawray(ray.origin, ray.direction * 10, color.yellow);

}

}

// draws a line in the scene view going through a point 200 pixels

// from the lower-left corner of the screen

//從屏幕左下角到200像素的點繪制一條線

function update () {

var ray : ray = camera.screenpointtoray (vector3(200,200,0));

debug.drawray (ray.origin, ray.direction * 10, color.yellow);

}

相關閱讀

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