camera.worldtoscreenpoint 世界转屏幕位置

2015-1-4 08:57| 发布者: 杨炎| 查看: 3030| 评论: 0|原作者: 蛮牛|来自: yzc88亚洲城脚本manual

摘要: camera.worldtoscreenpoint 世界转屏幕位置functionworldtoscreenpoint(position:vector3description描述transforms position from world space into screen space.从世界空间到屏幕空间变换位置。screenspace is de ...

camera.worldtoscreenpoint 世界转屏幕位置

functionworldtoscreenpoint(position:vector3

description描述

transforms position from world space into screen space.

从世界空间到屏幕空间变换位置。

screenspace is defined in pixels. the bottom-left of the screen is (0,0); the right-top is (pixelwidth,pixelheight). the z position is in world units from the camera.

屏幕空间以像素定义,屏幕左下为0,0,右上是(pixelwidth,pixelheight),z的位置是以世界单位衡量的到相机的距离。

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

publictransformtarget;

void update() {

vector3screenpos = camera.worldtoscreenpoint(target.position);

print("target is " + screenpos.x + " pixels from the left");

}

}

var target :transform;

function update () {

var screenpos :vector3= camera.worldtoscreenpoint (target.position);

print ("target is " + screenpos.x + " pixels from the left");

}

文章点评