找回密碼
 注冊帳號

掃一掃,訪問微社區

camera.worldtoscreenpoint 世界轉屏幕位置

2015-1-4 08:57| 發布者: 楊炎| 查看: 3277| 評論: 0|原作者: 蠻牛|來自: unity3d腳本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");

}

文章點評
女校游泳队彩金