Skip to main content

把2D文字和图片变到场景中去

var target : Transform;
var guitexture : GUITexture;
var guitext : GUIText;
var screenPos : Vector3;
var x : float;
var y : float;

function Update ()
{
screenPos = camera.WorldToScreenPoint (target.position);
x=screenPos.x;
y=screenPos.y;
guitexture.pixelInset = Rect (x-25, y-5, 50, 50);
guitext.pixelOffset = Vector2 (x-25, y-5);
guitext.material.color=Color.blue;
}