Unity官方文档:

Camera.ScreenPointToRay

public function ScreenPointToRay(position: Vector3): 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).

Screenspace is defined in pixels. The bottom-left of the screen is (0,0); the right-top is (pixelWidth,pixelHeight).

    // Draws a line in the scene view going through a point 200 pixels
// from the lower-left corner of the screen
function Update () {
var ray : Ray = camera.ScreenPointToRay (Vector3(,,));
Debug.DrawRay (ray.origin, ray.direction * , Color.yellow);
}

解释说明:

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).

返回的射线在世界坐标空间,从相机的近剪裁面开始穿过一个屏幕中的以像素为单位的点(x,y),(忽略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)点。

补充:

near plane 是近剪裁面的意思。

剪裁面是相机的可见范围,他就像一个被削了尖的金字塔,近剪裁面就是金字塔顶部,这也表示了相机可以看到的最近距离,远剪裁面就是金字塔的底部,表示相机可以看到的最远距离。

Camera.ScreenPointToRay 解析的更多相关文章

  1. Qualcomm 8X camera过程解析【转】

    本文转载自:http://blog.csdn.net/gabbzang/article/details/19906687 http://www.01yun.com/mobile_development ...

  2. camera render texture 游戏里的监控视角

    Camera里: 新建render texture并拖入到target texture里 新建材质球 拖入render texture      camera里的视角会在材质球上出现  新建一个pla ...

  3. Unity API 解析 (陈泉宏著)

    1 Application类 2 Camera类 3 GameObject类 4 HideFlags类 5 Mathf类 6 Matrix4x4类 7 Object类 8 Quaternion类 9 ...

  4. ScreenPointToRay - 近视口到屏幕的射线

    正如题目所说,ScreenPointToRay可以计算从Camera的近视口nearClip向前发射一条射线到屏幕上的点的坐标. 函数原型为: public Ray ScreenPointToRay( ...

  5. Unity3D脚本中文系列教程(十三)

    http://dong2008hong.blog.163.com/blog/static/469688272014032334486/ Unity3D脚本中文系列教程(十二) ◆ function G ...

  6. Unity3D脚本学习——运行时类

    AssetBundle 类,继承自Object.AssetBundles让你通过WWW类流式加载额外的资源并在运行时实例化它们.AssetBundles通过BuildPipeline.BuildAss ...

  7. [Unity3D]利用Raycast实现物体的选择与操作

    本文系作者原创 转载请注明出处 如果是一个2D的平面项目或者说需要在三维空间选择一个物体时(经常表现为抓取物件),我们需要用到Raycast事件 那么首先先说说什么是Raycast 按照字面上来理解的 ...

  8. 【Unity3D游戏开发】基础知识之Tags和Layers (三二)[转]

    Tags和Layers分别表示是Unity引擎里面的标签和层,他们都是用来对GameObject进行标识的属性,Tags常用于单个GameObject,Layers常用于一组的GameObject.添 ...

  9. [Unity2D]Tags和Layers

    Tags和Layers分别表示是Unity引擎里面的标签和层,他们都是用来对GameObject进行标识的属性,Tags常用于单个GameObject,Layers常用于一组的GameObject.添 ...

随机推荐

  1. HDU 4115 Eliminate the Conflict

    2-SAT,拆成六个点. #include<cstdio> #include<cstring> #include<cmath> #include<stack& ...

  2. HTML 引用Css样式的四种方式

    不才,只知道HTML引用CSS样式有四种方式,内部引用和外部引用各两种,因为老是忘记细节,记下了随时翻阅亦可方便如我般的初学者 内部引用方式1: 直接在标签内用 style 引用,如: <div ...

  3. ubuntu设置字体编码GBK和UTF-8

    http://www.xwuxin.com/?p=1155 http://zhidao.baidu.com/link?url=T6m7WDVOM1VBiUctkfkf1qO14lSMLhxg6MIRt ...

  4. Android Wi-Fi Display(Miracast)介绍

    地址:http://blog.csdn.net/innost/article/details/8474683 Android Wi-Fi Display(Miracast)介绍 2012年11月中旬, ...

  5. STM32的优先级NVIC_PriorityGroupConfig的理解及其使用(转)

    源:http://blog.csdn.net/yx_l128125/article/details/9703843 写作原由:因为之前有对stm32 优先级做过研究,但是没时间把整理的东西发表,最近项 ...

  6. ibatis resultMap 的用法

    先看个具体的例子: <resultMap id=”get-product-result” class=”com.ibatis.example.Product”> <result pr ...

  7. POJ 3449 Geometric Shapes

    判断两个多边形是否相交,只需判断边是否有相交. 编码量有点大,不过思路挺简单的. #include<cstdio> #include<cstring> #include< ...

  8. LNMP(Linux+Nginx+Mysql+PHP---源码)环境搭建

    LNMP(Linux+Nginx+Mysql+PHP(Perl)) Linux:[root@dep5 mysql]# cat /etc/issueRed Hat Enterprise Linux Se ...

  9. ZOJ 3929 Deque and Balls

    答案=所有情况中总共递减次数*2 放完i个和放完i-1个之间的递减次数是可以递推的. 有一部分是放完i-1个之后产生的,还有一部分是放完第i个之后新产生的. 注意减去多加的部分. 2的i次方可以打个表 ...

  10. MySQL show slave status命令参数

    ? Slave_IO_State SHOW PROCESSLIST输出的State字段的拷贝.SHOW PROCESSLIST用于从属I/O线程.如果线程正在试图连接到主服务器,正在等待来自主服务器的 ...