camera.worldtoviewportpoint 世界转视窗位置

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

摘要: camera.worldtoviewportpoint 世界转视窗位置functionworldtoviewportpoint(position:vector3description描述transforms position from world space into viewport space.从世界空间到视窗空间的变换位置。viewport ...

camera.worldtoviewportpoint 世界转视窗位置

functionworldtoviewportpoint(position:vector3

description描述

transforms position from world space into viewport space.

从世界空间到视窗空间的变换位置。

viewport space is normalized and relative to the camera. the bottom-left of the camera is (0,0); the top-right is (1,1). the z position is in world units from the camera.

视口空间是归一化的并相对于相机的。相机的左下为(0,0);右上是(1,1),z的位置是以世界单位衡量的到相机的距离。

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

publictransformtarget;

void update() {

vector3viewpos = camera.worldtoviewportpoint(target.position);

if (viewpos.x > 0.5f)

print("target is on the right side!");

else

print("target is on the left side!");

}

}

// finds out whether target is on the left or right side of the screen

//target在屏幕的左边还是右边

var target :transform;

function update () {

var viewpos :vector3= camera.worldtoviewportpoint (target.position);

// viewport coordinates range from zero to one

//视口坐标范围从0到1

if( viewpos.x > 0.5 )

print ("target is on the right side!");

else

print ("target is on the left side!");

}

相关阅读

文章点评
相关文章