找回密码
 注册帐号

扫一扫,访问微社区

camera.screenpointtoray 屏幕位置转射线

2015-1-4 07:17| 发布者: 杨炎| 查看: 3005| 评论: 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);

}

相关阅读

文章点评
相关文章