Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Unity3D的世界坐标转化成屏幕坐标

使用函数:Camera.WorldToScreenPoint原型:function WorldToScreenPoint (position : Vector3) : Vector3返回值:Vector3 中 x,y是屏幕中的位置,z是坐标到摄像机的距离 屏幕左下方是(0,0);右上方是(pixelWidth,pixelHeight)例程:
  1. var target : Transform;  
  2. function Update ()  
  3. {  
  4. var screenPos = camera.WorldToScreenPoint (target.position);  
  5. print ("target is " + screenPos.x + " pixels from the left");  
  6. }